CSC Final Exam (Past Exam Questions)
(T/F) If A and B are both false, then the expression A && B is false. - ANSWER-True
If A is true, B is false, C is false, what is the value of boolean expression A || B && C ? -
ANSWER-True
(T/F) Information in secondary memory is lost if the power is turned off. - ANSWER-
False
What is the result of the expression 2.0 + ? - ANSWER-5.0
What output would be produced when the following code is executed?
String state = "Mississippi"; System.out.println(state.replace("is", "S")); - ANSWER-
MSsSsippi
(T/F) A comment in a Java program is ignored by the compiler. - ANSWER-True
What will be the out put when count is 4, sum is 10, MAX is 100?
if (count > 5) if (sum < MAX) System.out.println("cattywampus"); else
System.out.println("snickersnee"); - ANSWER-Nothing will print out.
If the current value of the integer variable count is 2, what value will be stored in count
after the following line of code is executed?
count = count++ * 3; - ANSWER-6
Which of the following is a valid Java identifier?
1stPlace
first@Place
first place
$FIRSTPLACE - ANSWER-$FIRSTPLACE
(T/F) Java is an object-oriented programming language. - ANSWER-True
Which of the statement is NOT true?
Numeric primitive values in Java are signed.
The int and short data types both represent integers.
Internally, an uppercase letter ('A') is treated the same as its lowercase version ('a').
, The boolean data type represents a true or false value. - ANSWER-Internally, an
uppercase letter ('A') is treated the same as its lowercase version ('a').
Write code that prints the greater value of two integers that are stored in the variables
number1 and number2. If both integers are equal, print the value of number1. Assume
that both variables have already been declared and given values. - ANSWER-if
(number1 >= number2)
System.out.println(number1);
else
System.out.println(number2);
What output would be produced when the following code is executed?
String greeting = "hello";greeting = greeting.toUpperCase();
System.out.println(greeting); - ANSWER-HELLO
Given the following declarations, which assignment statement would NOT cause the
compiler to issue an error?
int num1 = 5;
final int NUM_2 = 3500;
double num3 = 7.29;
char num4 = '5'; - ANSWER-num3 = num1 +num3;
Which of the following will produce a compile time error?
Omitting a necessary semicolon in a program.
Misspelling a word in the output.
Dividing by zero.
Computing the wrong answer. - ANSWER-Omitting a necessary semicolon in a
program.
Which of the following is NOT an example of the attribute of a Car class?
Register the car
The car's model
The car's color
The car's brand - ANSWER-Register the car
(T/F) A constructor of a class can have a different name than the class name. -
ANSWER-False
Assume count is an integer with value of 1, and index is an integer with value of 0.
What output is printed by the following code?
(T/F) If A and B are both false, then the expression A && B is false. - ANSWER-True
If A is true, B is false, C is false, what is the value of boolean expression A || B && C ? -
ANSWER-True
(T/F) Information in secondary memory is lost if the power is turned off. - ANSWER-
False
What is the result of the expression 2.0 + ? - ANSWER-5.0
What output would be produced when the following code is executed?
String state = "Mississippi"; System.out.println(state.replace("is", "S")); - ANSWER-
MSsSsippi
(T/F) A comment in a Java program is ignored by the compiler. - ANSWER-True
What will be the out put when count is 4, sum is 10, MAX is 100?
if (count > 5) if (sum < MAX) System.out.println("cattywampus"); else
System.out.println("snickersnee"); - ANSWER-Nothing will print out.
If the current value of the integer variable count is 2, what value will be stored in count
after the following line of code is executed?
count = count++ * 3; - ANSWER-6
Which of the following is a valid Java identifier?
1stPlace
first@Place
first place
$FIRSTPLACE - ANSWER-$FIRSTPLACE
(T/F) Java is an object-oriented programming language. - ANSWER-True
Which of the statement is NOT true?
Numeric primitive values in Java are signed.
The int and short data types both represent integers.
Internally, an uppercase letter ('A') is treated the same as its lowercase version ('a').
, The boolean data type represents a true or false value. - ANSWER-Internally, an
uppercase letter ('A') is treated the same as its lowercase version ('a').
Write code that prints the greater value of two integers that are stored in the variables
number1 and number2. If both integers are equal, print the value of number1. Assume
that both variables have already been declared and given values. - ANSWER-if
(number1 >= number2)
System.out.println(number1);
else
System.out.println(number2);
What output would be produced when the following code is executed?
String greeting = "hello";greeting = greeting.toUpperCase();
System.out.println(greeting); - ANSWER-HELLO
Given the following declarations, which assignment statement would NOT cause the
compiler to issue an error?
int num1 = 5;
final int NUM_2 = 3500;
double num3 = 7.29;
char num4 = '5'; - ANSWER-num3 = num1 +num3;
Which of the following will produce a compile time error?
Omitting a necessary semicolon in a program.
Misspelling a word in the output.
Dividing by zero.
Computing the wrong answer. - ANSWER-Omitting a necessary semicolon in a
program.
Which of the following is NOT an example of the attribute of a Car class?
Register the car
The car's model
The car's color
The car's brand - ANSWER-Register the car
(T/F) A constructor of a class can have a different name than the class name. -
ANSWER-False
Assume count is an integer with value of 1, and index is an integer with value of 0.
What output is printed by the following code?