COMP 308 JAVA FOR PROGRAMMERS
FINAL COMPREHENSIVE EXAM 2026 TIPS
POSSIBLE QUESTIONS STUDY GUIDE Q&A
UPDATED
⩥ What is an object? Answer: An entity in the real world that can be
distinctly identified.
⩥ What is a class? Answer: A template that defines objects of the same
type.
⩥ What is a constructor? Answer: A special method invoked to create an
object.
⩥ What must constructors have? Answer: Constructors must have the
same name as the class itself, can be multiple in a class, do not have a
return type, and are invoked using the new operator.
⩥ What is the output of the code analyzing TempClass? Answer: The
program has a compile error because TempClass does not have a default
constructor.
⩥ What does Circle x = new Circle() represent? Answer: x contains a
reference to a Circle object.
, ⩥ How do you create an object of the Date class? Answer: You can
create it using 'java.util.Date date = new java.util.Date();'.
⩥ What is the issue with the radius variable in the area calculation code?
Answer: The program has no compile errors but will get a runtime error
because radius is not initialized.
⩥ What happens when you try to access test.x in the Test class? Answer:
The program has a runtime NullPointerException because test is null
while executing test.x.
⩥ What is true about Random objects? Answer: If two Random objects
have the same seed, the sequence of random numbers obtained from
these two objects is identical.
⩥ What is an instance method? Answer: A method that is associated with
an individual object.
⩥ What is the output of the second println statement in the Foo class?
Answer: f2.i is 1 f2.s is 2.
⩥ Where should the static keyword be added in the Test class? Answer:
In line 4 and line 8.
FINAL COMPREHENSIVE EXAM 2026 TIPS
POSSIBLE QUESTIONS STUDY GUIDE Q&A
UPDATED
⩥ What is an object? Answer: An entity in the real world that can be
distinctly identified.
⩥ What is a class? Answer: A template that defines objects of the same
type.
⩥ What is a constructor? Answer: A special method invoked to create an
object.
⩥ What must constructors have? Answer: Constructors must have the
same name as the class itself, can be multiple in a class, do not have a
return type, and are invoked using the new operator.
⩥ What is the output of the code analyzing TempClass? Answer: The
program has a compile error because TempClass does not have a default
constructor.
⩥ What does Circle x = new Circle() represent? Answer: x contains a
reference to a Circle object.
, ⩥ How do you create an object of the Date class? Answer: You can
create it using 'java.util.Date date = new java.util.Date();'.
⩥ What is the issue with the radius variable in the area calculation code?
Answer: The program has no compile errors but will get a runtime error
because radius is not initialized.
⩥ What happens when you try to access test.x in the Test class? Answer:
The program has a runtime NullPointerException because test is null
while executing test.x.
⩥ What is true about Random objects? Answer: If two Random objects
have the same seed, the sequence of random numbers obtained from
these two objects is identical.
⩥ What is an instance method? Answer: A method that is associated with
an individual object.
⩥ What is the output of the second println statement in the Foo class?
Answer: f2.i is 1 f2.s is 2.
⩥ Where should the static keyword be added in the Test class? Answer:
In line 4 and line 8.