1Why do computers use zeros and ones?
because digital devices have two stable states and it is natural to use one state for 0 and the other for 1
2_______ are instructions to the computer.
Programs and Software's
3________ is the physical aspect of the computer that can be seen.
Hardware
4Computer can execute the code in ________.
machine language
5________ is an operating system.
6Java ________ can run from a Web browser.
applets
7________ is interpreted.
Java
8The main method header is written as:
public static void main(String[] args)
9Which of the following statements is correct to display Welcome to Java on the console?
System.out.print("Welcome to Java");
System.out.println("Welcome to Java");
10The JDK command to compile a class in the file Test.java is
javac Test.java
11Java compiler translates Java source code into ________.
Java bytecode
12The extension name of a Java bytecode file is
class
13________ is a software that interprets Java bytecode.
Java virtual machine
14The extension name of a Java source code file is
.java
15Every statement in Java ends with ________.
a semicolon ( ; ), known as the statement terminator.
16A block is enclosed inside ________.
braces
17________ are secondary storage.
floppy disk, hard disk, CD
18The keywords in Java are all in lowercase.
True
19You use ________ to run a Java program.
Java
20Which of the following is a valid identifier?
radius
21Which of the following are correct ways to declare variables? A)int length, width; B)int length; int width; C)int length, int width; D)int length; width;
A)int length, width;
B)int length; int width;
22________ is the Java assignment operator.
=
23Which of the following assignment statements is incorrect.
A)i=j=k=1;
B)i=1=j=1=k=1;
C)i==j==k==1;
D)i=1; j=1; k=1;
B)i=1=j=1=k=1;
C)i==j==k==1;
24To declare a constant MAX_LENGTH inside a method with value 99.98, you write
final double MAX_LENGTH=99.98;
25Which of these data type requires the most amount of memory?
A)byte B)short C)long D)int
C)long
26To declare an int variable number with initial value 2, you write:
A)int number=2l;
B)int number=2L;
C)int number=2;
D)int number=2.0;
int number=2;
27Which of the following expressions will yield 0.5?
A)(double) (1 / 2)
B)1 / 2
C)1.0 / 2
D)1 / 2.0
E)(double) 1 / 2
C)1.0 / 2
D)1 / 2.0
E)(double) 1 / 2
28Which of the following expression results in a value 1?
A)2 % 1
B)15 % 4
C)25 % 5
D)37 % 6
D)37 % 6
29Analyze the following code.public class Test {public static void main(String[ ] args) {int month=09;System.out.println("month is "+month);}}
A)The program displays month is 09
B)The program displays month is 9.0
C)The program displays month is 9
D)The program has a syntax error, because 09 is an incorrect literal value.
The program has a syntax error, because 09 is an incorrect literal value.
30Which of the following assignment statements is illegal?
A)float f=-34;
B)int t=23;
C)short s=10;
D)int t=4.5;
E)int t=(int)false;
D) int t=4.5;
E) int t=(int)false;
31What is the value of (double)5/2?
A)3;
B)3.0;
C)2.5;
D)2;
E)2.0;
2.5
32A Java character is stored in ________.
two bytes
3333)33)Which of the following statement prints smith\exam1\test.txt?
A)System.out.println("smith\exam1\test.txt");
B)System.out.println("smith"\exam1"\test.txt");
C)System.out.println("smith\"exam1\"test.txt");
D)System.out.println("smith\\exam1\\test.txt");
D. System.out.println("smith\\exam1\\test.txt");
34The ________ method parses a string s to an int value.
A)integer.parseInteger(s);
B)integer.parseInt(s);
C)Integer.parseInt(s);
D)Integer.parseInteger(s);
C. Integer.parseInt(s);
35The ________ method parses a string s to a double value.
double.parse(s);
36The expression (int)(76.0252175 * 100) / 100 evaluates to ________.
A)76.02
B)76.0252175
C)76.03
D)76
D) 76
37If a program compiles fine, but it produces incorrect result, then the program suffers ________.
a logic error
38You can always assign a value of long type to a variable of int type without loss of precision.
False
39You can always assign a value of int type to a variable of long type without loss of information.
True
40A variable may be assigned a value only once in the program.
False
41You can change the value of a constant.
False
42To add a to b and store result in b, you write:
b+=a;
43To declare a constant PI, you write
final double PI=3.14159;
44A Java statement ends with a ________.
semicolon (;)
45Which of the following operators has the highest precedence?
A)/
B)+
C)*
D)casting
casting
46An int variable can hold ________.
A)'x'
B)93
C)True
D)98.3
E)A and B
E)A and B
47If you attempt to add an int, a byte, a long, and a double, the result will be a ________ value.
double;
48What is the printout of the following code:double x=10.1;int y=(int)x;System.out.println("x is "+x+" and y is "+y);
A)x is 10.0 and y is 10.0
B)x is 10.1 and y is 10
C)x is 10.1 and y is 10.0
D)x is 10 and y is 10
E)x is 11 and y is 11
B) x is 10.1 and y is 10
49In Java, the word true is ________.
D) a Boolean literal
50Suppose x=10 and y=10 what is x after evaluating the expression (y > 10) & (x++>10).
A)9
B)11
C)10
B) 11
51Suppose x=10 and y=10 what is x after evaluating the expression (y > 10) && (x++>10).
C)10
52Which of the following code displays the area of a circle if the radius is positive.
A)if (radius>=0)
System.out.println(radius * radius * Math.PI);
B)if (radius<=0) System.out.println(radius * radius * Math.PI);
C)if (radius !=0) System.out.println(radius * radius * Math.PI);
D)if (radius>0) System.out.println(radius * radius * Math.PI)
D)if (radius>0) System.out.println(radius * radius * Math.PI);
5353)What is y after the following switch statement is executed? x=3;switch (x+3) {case 6: y=0;case 7: y=1;default: y+=1;}
A)3
B)2
C)4
D)1
B) 2
54What is the printout of the following switch statement?char ch='b';switch (ch) {case 'a':System.out.print(ch);case 'b':System.out.print(ch);case 'c':System.out.print(ch);case 'd':System.out.print(ch);}
A)b
B)bcd
C)abcd
D)bbb
E)bb
E)bb
55Analyze the following program fragment: int x; double d=1.5; switch (d) {case 1.0: x=1; case 1.5: x=2;case 2.0: x=3;}
A)The switch control variable cannot be double.
B)The program has a syntax error because the required break statement is missing in the switch statement.
C)The program has a syntax error because the required default case is missing in the switch statement.
D)No errors
A) The switch control variable cannot be double.
56You can always convert a switch statement to an equivalent if statement.
True
57The order of the precedence (from high to low) of the operators+, *, &&, ||, & is:
A)&, ||, &&, *,+
B)*,+, &, ||, &&
C)*,+, &&, ||, &
D)&&, ||, &, *,+
E)*,+, &, &&, ||
D)&&, ||, &, *,+
58What is the value of the following expression? true || true && false
True