Fundamentals, OOP & Collections
CS202 — Object-Oriented Programming | Undergraduate CS
Questions & Verified Answers
, Java Programming — Fundamentals & OOP
30 questions covering Java syntax, operators, OOP principles, ArrayList, exceptions, constructors, and
best practices.
Q1. Which statement about Java constructors is incorrect?
A. Constructors must have the same name as the class
B. Constructors do not have a return type
C. Constructors can be overloaded
D. A class can have only one constructor
E. A constructor may be static
Answer: E. A constructor may be static.
Constructors in Java cannot be declared static. They are instance-specific.
Option D is also incorrect (a class CAN have multiple constructors via overloading),
but E describes a property that is fundamentally impossible — constructors cannot be static.
Q2. What is the output of: System.out.println(5 + "5");
A. 10
B. 55
C. 5+5
D. Compile error
Answer: B. 55
When + is used with a String operand, Java performs string concatenation.
The integer 5 is converted to "5", then concatenated with "5" to produce "55".
Q3. What is the default value of a boolean instance variable in Java?
A. true
B. false
C. null
D. 0
Answer: B. false
Java default values for instance fields: boolean=false, int=0, double=0.0, Object=null.
Local variables do NOT have default values — they must be initialized before use.
Q4. What is the result of 24 % 5?
A. 4.8
B. 4
C. 5
D. 1
Answer: B. 4
% returns the remainder of integer division. 24 ÷ 5 = 4 remainder 4.
For negative numbers: -24 % 5 = -4 (sign follows the dividend in Java).
Q5. What does new ArrayList<>(2) create?
A. A list with 2 elements