Java Midterm

Ace your homework & exams now with Quizwiz!

Which of the following is not a reserved word in Java?

All

When using a method from another class, what two things must be included with the method call for it to work properly?

Object or Class name and dot operator

A loop that continues to execute endlessly is called an _____ loop.

infinite

The devices that feed data and programs into computers are called _______.

input devices

What is the correct syntax for a declaration?

int a;

An expression such as str.length(); is an example of a(n)_____.

method call

Which of the following is an accurate method call?

methodName();

The ____________ method reads an integer value.

nextInt()

The ____________ method reads a full line from user.

nextLine()

Consider the following program: public class HelloWorld { public static void main(String args) { System.out.print("Hello World ") } } What will the program output?

nothing, program has errors. missing (String [] args)

In the class String, the substring method inserts a string into another string.

False

The following statement constructs a new Scanner object that makes your program interactive: Scanner console = new Scanner();

False

Value-returning methods must have paramaters

False

for loops do not allow more that one initialization in the method header.

False

The following are String methods: nextInt() nextDouble() next() nextLine()

False, these are Scanner Methods

Which of the following is a reserved word in Java?

void

What does the following code output? for (int a = 0; a < 3; a++) ; { System.out.println("\"Be Great Today!!\""); }

"Be Great today!!" once

The byte code for a Java program is saved in the file with the ________ extension.

.class

If a = 4; and b = 3; ,then after the statement a = b; executes, the value of b is 4 and the value of a is 3.

False

A global variable is declared inside a method and is accessible only in that method

False

A method that includes a return type can return two or more values.

False

All methods pass parameters and return a value.

False

An identifier can be a sequence of characters and integers.

False

What are the key compounds of a for loop header?

Initialization, Test, Update

Bytecode is the machine language for

Java Virtual Machine

_______ are executable statement(s) that inform the user what to do.

Prompt(s)

charAt(2), a string method used to:

Return the third character in the string

A formal parameter is a variable that appears in the method header.

True

A local variable is declared in a method and a global variable at a class level. Global variables are accessible anywhere inside the program while local variables are not.

True

A loop is a control structure that causes certain statements to be executed over and over until certain conditions are met.

True

A nested for loop refers to a loop(s) inside of another loop.

True

An actual parameter is the value or expression that appears inside parentheses of a method call.

True

Both System.out.println and System.out.print can be used to output a string on the console.

True

In Java, the result of the expression 28.0/7 is 4.0

True

Suppose x = 8. After the execution of the statement y = x++; y is 8 and x is 8.

True

Supposed that index is an int variable. The statement index = index + 1; is equivalent to index++;

True

Supposed x = 18.6. The output of the statement System.out.println(xx); will not execute resulting in an error.

True

The basic commands that a computer performs are the input (get data), output (display results), storage, and performance of arithmetic and logical operations.

True

The charAt(parameter) method passes the index of type int, which returns the character located there.

True

The devises that feed data and programs into computers are called input devices.

True

The for loop is categorized as a definite loop

True

The pair of characters // is used for single line comments.

True

Type casting is the conversion of one type to another.

True

String objects are immutable

True (String object values cannot be changed)

The digit 0 or 1 is called a binary digit, or _______.

bit

Based on the following code, select the correct method call to execute the method: public static void calculateAvg (int a, int b, double tax) { System.out.println(a * b); }

calculateAvg(5, 10, 3.25);

Which data type will allow the following character '&' be to stored and used within a program?

char

In a Java program, the file name must be the same as

class name

Which is the correct syntax for initializing a variable?

double gpa = 3.45;

Consider the following program. public class CircleArea { static Scanner console = new Scanner(System.in); static final float PI = 3.14; public static void main(String[]args) { float r; float area; r = console.nextDouble(); area = PI * r * r; System.out.println("Area = " + area); } } To successfully compile this program, which of the following import statement is required?

import java.util.*;

When creating a method that returns a value, what must change in the following method header? public static void printAverage (int a, int b) { }

return type

Multiple line comments are enclosed between */ and /*

true


Related study sets

Pharmacology Chapter 41 Drug Therapy for Diabetes Mellitus

View Set

Principles of Management: Chapter 1

View Set

International Finance Final Exam

View Set

Large Animal Surgery II: Dentistry

View Set

Chapter 8: Social Media Information Systems

View Set

NR 226 Final Exam Practice Questions

View Set