CMSC Exam
Verified Exam Questions and Answers Latest update 2026/2027
Question:
1. Which of the following lines of code correctly writes
"Hello" to the screen.
Answer:
System.out.println("Hel-
lo");
Question:
2. Fill in the blanks of the code below : main(
args){
Answer:
Public, static, void, String[]
Question:
3. The class name does not have to be the same as the
file name
Answer:
False
Question:
4. The command to compile a Java program is:
Hello.java.
Answer:
Java
Question:
5. Explain the steps that need to happen to take code 1. Code is written
from it being written to it running and producing out- 2. Code is compiled
put. 3. The byte code is read
Answer:
Question:
6. What does the virtual machine do? Choose all answers 1. runs the class file
that apply.
,Answer:
2. runs the byte code
Question:
7. Logic errors are the hardest errors to find. T/F
Answer:
True
Question:
8. While running a program, it unexpectedly stops. What 1. runtime
type of error is that? Choose all answers that apply. 2. logic
Answer:
Question:
9. Write the algorithm for the following computer prob- Set ASSESS_PERCENT =
lem:
Bear Corporation needs a program to calculate their Enter month1Sales,
quarterly assessment fee. They will total the sales for month2Sales,
the past quarter (a three month period) and the pay Month3Sales
22% of the total sales as their quarterly assessment Calculate totalSales by
fee.
month2Sales,
Month3Sales
Answer:
0.22
adding month1Sales,
Calculate assessmentFee
by totalSales * AS-
SESS_PERCENT
Output assessmentFee
Question:
10. What is a variable? Choose all parts below that are
relevant.
Answer:
1. can change
2. memory location
3. named
, Question:
11. Name two primitive Java data types that represent
whole numbers.
Answer:
int, byte, short, long
Question:
12. Name two primitive Java data types that represent
floating point numbers.
Answer:
float, double
Question:
13. For each error shown below match it to the correct out- 1. Compile-time error
put: a compile-time error, run-time error, or no error. 2. run-time error
Answer:
4. compile-time error
5. compile-time error
Question:
3. compile-time error
Answer:
6. no error
Question:
1. System.out.Println("Greetings, Planet Earth!");
Answer:
Question:
2. System.out.println();
Answer:
Question:
3. float scale = 7854.345368564323;
Answer:
Verified Exam Questions and Answers Latest update 2026/2027
Question:
1. Which of the following lines of code correctly writes
"Hello" to the screen.
Answer:
System.out.println("Hel-
lo");
Question:
2. Fill in the blanks of the code below : main(
args){
Answer:
Public, static, void, String[]
Question:
3. The class name does not have to be the same as the
file name
Answer:
False
Question:
4. The command to compile a Java program is:
Hello.java.
Answer:
Java
Question:
5. Explain the steps that need to happen to take code 1. Code is written
from it being written to it running and producing out- 2. Code is compiled
put. 3. The byte code is read
Answer:
Question:
6. What does the virtual machine do? Choose all answers 1. runs the class file
that apply.
,Answer:
2. runs the byte code
Question:
7. Logic errors are the hardest errors to find. T/F
Answer:
True
Question:
8. While running a program, it unexpectedly stops. What 1. runtime
type of error is that? Choose all answers that apply. 2. logic
Answer:
Question:
9. Write the algorithm for the following computer prob- Set ASSESS_PERCENT =
lem:
Bear Corporation needs a program to calculate their Enter month1Sales,
quarterly assessment fee. They will total the sales for month2Sales,
the past quarter (a three month period) and the pay Month3Sales
22% of the total sales as their quarterly assessment Calculate totalSales by
fee.
month2Sales,
Month3Sales
Answer:
0.22
adding month1Sales,
Calculate assessmentFee
by totalSales * AS-
SESS_PERCENT
Output assessmentFee
Question:
10. What is a variable? Choose all parts below that are
relevant.
Answer:
1. can change
2. memory location
3. named
, Question:
11. Name two primitive Java data types that represent
whole numbers.
Answer:
int, byte, short, long
Question:
12. Name two primitive Java data types that represent
floating point numbers.
Answer:
float, double
Question:
13. For each error shown below match it to the correct out- 1. Compile-time error
put: a compile-time error, run-time error, or no error. 2. run-time error
Answer:
4. compile-time error
5. compile-time error
Question:
3. compile-time error
Answer:
6. no error
Question:
1. System.out.Println("Greetings, Planet Earth!");
Answer:
Question:
2. System.out.println();
Answer:
Question:
3. float scale = 7854.345368564323;
Answer: