All Correct Answers 2026.
Study the following Java code:
public final class Test {
void f() {
System.out.print(1);
}
}
class Test2 extends Test {
void f() {
System.out.print(2);
}
}
class Program {
public static void main (String[] args){
Test obj = new Test2();obj.f();
}
}
What is it's result?
a. 2
b. 1
c. None of the others
d. Compile-time error - Answer Compile-time error
Study the following code:
public class Test {
int x= 5;
int y=2;
public static void main (String[] args){
Test obj;
, obj.x=10;
obj.y=20;
System.out.println(obj.x + obj.y);
}
}
What is output?
a. 7
b. 30
c. Error
d. None of the others - Answer Error
Hiding internal data from the outside world, and accessing it only through publicly exposed
methods is known as data .........
a. Specification
b. Aggregation
c. Grouping
d. Encapsulation - Answer Encapsulation
Inheritance implementations in OO languages support a way to ...................
a. Re-use codes
b. Cause more complexity in programming
c. Reduce the cost of software development
d. Increase the cost of software deveopment - Answer Re-use codes
Reduce the cost of software development
Common behavior can be defined in a superclass and inherited into a subclass using
the..........keyword.
A collection of methods with no implementation is called an ........
a. None of the others