
OOPJ Quiz
Authored by GAUTAMI UPPADA
Other
University
Used 2+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
In the context of encapsulation, what is the primary purpose of using private instance variables with public getter and setter methods in a Java class?
To allow unrestricted access to the class’s internal data
To ensure that the class can only be instantiated within the same package
To hide the internal state of the object and provide controlled access to it
To enable automatic memory management by the JVM
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
When a Java program is compiled, the JVM generates bytecode. What happens if a .class file is executed on a machine with a different architecture than the one it was compiled on?
The program will fail to execute due to architecture mismatch
The JVM interprets the bytecode, making it platform-independent
The bytecode is recompiled into native code specific to the new architecture
The JRE throws a ClassFormatError at runtime
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider a class with a static initialization block that initializes a static array. If an exception occurs in the static block during class loading, what will happen?
The exception is caught automatically by the JVM, and the class is loaded
The class loading fails, and a ExceptionInInitializerError is thrown
The static block is skipped, and the array remains uninitialized
The program continues execution but skips the static array initialization
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
In a multilevel inheritance hierarchy, a subclass overrides a method from its parent class. If the parent class method is declared with the final keyword, what is the outcome?
The method can be overridden only if the subclass is in the same package
Correct Answer: B
The method is overridden, but the final keyword is ignored in the subclass
The subclass can override the method, but it must also mark it as final
The subclass cannot override the method, and a compile-time error occurs
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
A Java interface defines a default method, and a class implementing this interface provides its own implementation of the same method. Which implementation is invoked when the method is called on an instance of the class?
The interface’s default method is always invoked
The method invocation depends on the access modifier of the class’s method
The class’s implementation overrides the default method
A runtime exception is thrown due to method conflict
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
In a try-catch block, a finally block contains a return statement. If both the try block and the catch block also contain return statements, which return value takes precedence?
The return value from the finally block
The return value from the try block
The return value from the catch block
A NullPointerException is thrown
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
When using a StringBuilder to modify a string, what happens to the original string if the StringBuilder was initialized with a String object?
The original String object is modified in the string pool
The StringBuilder modifies the string pool, causing a runtime error
The original String is garbage collected immediately
The original String remains unchanged, and StringBuilder operates on a separate copy
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Anime Quiz
Quiz
•
KG - Professional Dev...
11 questions
Types of Mass Media
Quiz
•
10th Grade - Professi...
10 questions
Meet & Mingle emoji
Quiz
•
University
10 questions
Leaders of The World
Quiz
•
KG - University
11 questions
Principles of Economics(2)
Quiz
•
University
12 questions
possessive adjectives
Quiz
•
University
15 questions
MIS Chapter 6 Review
Quiz
•
University
10 questions
Facts and fiction about Oulu
Quiz
•
9th Grade - University
Popular Resources on Wayground
8 questions
Spartan Way - Classroom Responsible
Quiz
•
9th - 12th Grade
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
14 questions
Boundaries & Healthy Relationships
Lesson
•
6th - 8th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
3 questions
Integrity and Your Health
Lesson
•
6th - 8th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
9 questions
FOREST Perception
Lesson
•
KG
20 questions
Main Idea and Details
Quiz
•
5th Grade
Discover more resources for Other
20 questions
Disney Trivia
Quiz
•
University
7 questions
Fragments, Run-ons, and Complete Sentences
Interactive video
•
4th Grade - University
7 questions
Renewable and Nonrenewable Resources
Interactive video
•
4th Grade - University
10 questions
DNA Structure and Replication: Crash Course Biology
Interactive video
•
11th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
20 questions
Implicit vs. Explicit
Quiz
•
6th Grade - University
14 questions
Ch.3_TEACHER-led
Quiz
•
University
7 questions
Comparing Fractions
Interactive video
•
1st Grade - University