Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 7 pages
Exam (elaborations)

Java Programming Fundamentals and OOP — Exam Questions and Answers

Document preview thumbnail
Preview 2 out of 7 pages

Comprehensive exam Q&A for Java Programming and Object-Oriented Programming courses. Covers 30 multiple-choice and short-answer questions with clear, verified answers and explanations. Topics covered: - Java syntax rules, identifiers, and operators - Default values, data types, and type casting - Constructors, this keyword, and method overloading - Conditionals, loops, and short-circuit evaluation - ArrayList methods and index-based operations - String comparison (== vs .equals()) - Exception types: ArrayIndexOutOfBoundsException, NullPointerException - The four OOP pillars: encapsulation, abstraction, inheritance, polymorphism - Method overriding vs overloading - instanceof operator and dynamic binding - Static vs instance methods Includes tricky exam questions where correct answer explanations help you avoid common Java pitfalls.

Content preview

Java Programming
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

Document information

Uploaded on
May 13, 2026
Number of pages
7
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$15.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
1
Followers
0
Items
38
Last sold
2 months ago


Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions