
OOPJ Quiz

Quiz
•
Other
•
University
•
Easy
GAUTAMI UPPADA
Used 2+ times
FREE Resource
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
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
Aaruth Quiz

Quiz
•
University
15 questions
Quiz on Object Oriented Programming and Java

Quiz
•
University
10 questions
Arena Games x Tangem QUIZ

Quiz
•
University
10 questions
Quiz OOP 1

Quiz
•
University
10 questions
Java Strings

Quiz
•
1st Grade - Professio...
15 questions
Object Oriented Programming Language Quiz 3

Quiz
•
University
10 questions
QUIZ W9 - FUNCTION

Quiz
•
University
11 questions
Mini game thuyết trình nhóm 2

Quiz
•
University
Popular Resources on Wayground
55 questions
CHS Student Handbook 25-26

Quiz
•
9th Grade
10 questions
Afterschool Activities & Sports

Quiz
•
6th - 8th Grade
15 questions
PRIDE

Quiz
•
6th - 8th Grade
15 questions
Cool Tool:Chromebook

Quiz
•
6th - 8th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
20 questions
Bullying

Quiz
•
7th Grade
18 questions
7SS - 30a - Budgeting

Quiz
•
6th - 8th Grade
Discover more resources for Other
36 questions
USCB Policies and Procedures

Quiz
•
University
4 questions
Benefits of Saving

Quiz
•
5th Grade - University
20 questions
Disney Trivia

Quiz
•
University
2 questions
Pronouncing Names Correctly

Quiz
•
University
15 questions
Parts of Speech

Quiz
•
1st Grade - University
1 questions
Savings Questionnaire

Quiz
•
6th Grade - Professio...
26 questions
Parent Functions

Quiz
•
9th Grade - University
18 questions
Parent Functions

Quiz
•
9th Grade - University