APCSA MULTIPLE CHOICE FINAL QUESTINS
Program errors can be caused by
A) Bad Syntax
B) Code that compiles fine but is interpreted differently from what the programmer
intended
C) Code that compiles fine and behaves just as the Programmer intended
D) A& B only
E) A, B, & C
F) None of these cause program errors - Answer -D
What is a "Scanner"?
A) A module in the Java compiler that scans source code for syntax errors.
B)A module in the Java interpreter that scans the current directory for .class files.
C) A library class in the java.util package that helps to read user input from the
keyboard
D) A library class that helps to read command-line parameters in a program - Answer -
C
Consider the following methods:
public void fun(int a, int b)
{
a+=b;
b+=a;
}
What is the output from the following code?
int x=3, y=5;
fun(x, y);
System.out.println(x+""+y);
A) 3 5
B) 3 8
C) 3 13
D) 8 8
E) 8 13 - Answer -A
What value is stored in number by executing the statement number=7/2;? Assume that
number is declared to be an integer number data type.
A) 3.5
B) 3
C) 1
D) 4 - Answer -B
What value is stored in number by executing the statement number=7.0/2.0;? Assume
that number is declared to be a real number data type.
A) 3.5
, B) 3
C) 1
D) 4 - Answer -A
What is the output of the program segment below?
String var1="100"
String var2="200";
System.out.println(var1+var1);
System.out.println(var2+var2);
A)100
200
B)100200
200100
C)100100
200200
D)200
400 - Answer -C
What is the output of the program segment below?
String age="25";
String firstName="John";
String lastName="Doe";
System.out.println(firstName+" "+lastName+" "age);
A)JohnDoe25
B)25JohnDoe
C)John
Doe
25
D) John Doe 25 - Answer -D
Consider the two program segments below
Segmant A Segment B
int a; int a=100;
int b; int b=200;
a=100;
b=200;
What is true about the comparison of these two segments?
A) Segment A is correct and Segment B is not correct.
B) Segment A is incorrect and Segment B is correct.
C) Segment A and Segment B are both correct.
D) Segment A and Segment B are both incorrect. - Answer -C
Consider the following Java program:
//Program Greetings17
public class Greetings17
{
Program errors can be caused by
A) Bad Syntax
B) Code that compiles fine but is interpreted differently from what the programmer
intended
C) Code that compiles fine and behaves just as the Programmer intended
D) A& B only
E) A, B, & C
F) None of these cause program errors - Answer -D
What is a "Scanner"?
A) A module in the Java compiler that scans source code for syntax errors.
B)A module in the Java interpreter that scans the current directory for .class files.
C) A library class in the java.util package that helps to read user input from the
keyboard
D) A library class that helps to read command-line parameters in a program - Answer -
C
Consider the following methods:
public void fun(int a, int b)
{
a+=b;
b+=a;
}
What is the output from the following code?
int x=3, y=5;
fun(x, y);
System.out.println(x+""+y);
A) 3 5
B) 3 8
C) 3 13
D) 8 8
E) 8 13 - Answer -A
What value is stored in number by executing the statement number=7/2;? Assume that
number is declared to be an integer number data type.
A) 3.5
B) 3
C) 1
D) 4 - Answer -B
What value is stored in number by executing the statement number=7.0/2.0;? Assume
that number is declared to be a real number data type.
A) 3.5
, B) 3
C) 1
D) 4 - Answer -A
What is the output of the program segment below?
String var1="100"
String var2="200";
System.out.println(var1+var1);
System.out.println(var2+var2);
A)100
200
B)100200
200100
C)100100
200200
D)200
400 - Answer -C
What is the output of the program segment below?
String age="25";
String firstName="John";
String lastName="Doe";
System.out.println(firstName+" "+lastName+" "age);
A)JohnDoe25
B)25JohnDoe
C)John
Doe
25
D) John Doe 25 - Answer -D
Consider the two program segments below
Segmant A Segment B
int a; int a=100;
int b; int b=200;
a=100;
b=200;
What is true about the comparison of these two segments?
A) Segment A is correct and Segment B is not correct.
B) Segment A is incorrect and Segment B is correct.
C) Segment A and Segment B are both correct.
D) Segment A and Segment B are both incorrect. - Answer -C
Consider the following Java program:
//Program Greetings17
public class Greetings17
{