Computer Knowledge
Object-Oriented Programming
2,686 Questions
Object-oriented programming questions test core computer science concepts like classes, inheritance, polymorphism, and encapsulation. The focus includes Java program structures, method overloading, and memory allocation for objects. This topic is essential for technical sections in various recruitment tests.
Java class definitionsMethod overriding rulesPolymorphism conceptsGeneric type parametersMemory allocation in objects
Object-Oriented Programming Questions
-
Compilation Error
-
Run time Error
-
BOTH
-
None of these
A
Correct answer
Explanation
In Java, a public class name must match the filename. If you save a class with a different name than specified, the compiler will fail with a compilation error. The code won't even reach runtime.
-
only 1
-
2
-
No need of void main
-
infinite
A
Correct answer
Explanation
A Java class can have only one main method with the signature public static void main(String[] args). This is the entry point that the JVM looks for when executing the class. Overloading main with different parameters is technically possible but only the standard signature serves as the entry point.
-
rt.jar
-
java.classes.jar
-
pt.jar
-
rm.jar
-
JAVA/JDK 1.5/JRE/LIB/rt.jar
-
JAVA/JDK 1.5/JRE/LIB/rm.jar
-
you cant see
-
JAVA/JDK 1.5/BIN/LIB/rt.jar
A
Correct answer
Explanation
Constructor chaining allows calling one constructor from another using the this() keyword in C# or similar syntax in other languages. This avoids code duplication when initializing objects through different constructor overloads.
A
Correct answer
Explanation
The Set interface is designed for collections that contain no duplicate elements. Implementations like HashSet enforce uniqueness without imposing any ordering requirement. Lists allow duplicate elements, Maps store key-value pairs, and Vector (a legacy List implementation) also permits duplicates.
B
Correct answer
Explanation
In object-oriented programming and Java, a class is not considered a subclass of itself; it is only identical to itself. Inheritance relationships require two distinct classes.
B
Correct answer
Explanation
Method overloading requires different parameter lists (different number, types, or order of parameters). Return type alone is insufficient because the compiler wouldn't know which method to call at compile time - the signature must be unique based on parameters, not return type.
-
Thread Groups
-
Reflection
-
Floating point Numbers
-
JNI
C
Correct answer
Explanation
Unlike CLDC 1.0, the CLDC 1.1 specification introduced native support for floating-point numbers (float and double data types) and their corresponding operations.
-
Interface in Java
-
pointer in C or C++
-
function pointer in C or C++
-
Interface in .NET
C
Correct answer
Explanation
Delegates in .NET are type-safe object references that encapsulate a method. This concept is conceptually identical to function pointers in C or C++.
-
private
-
protected
-
protected internal
-
It is not possible to do it
C
Correct answer
Explanation
protected internal combines both access modifiers: accessible within the current assembly (internal) AND to derived classes in other assemblies (protected). private is class-only, protected excludes current assembly, and option D is incorrect.
B
Correct answer
Explanation
Serializable is a marker interface - it has NO methods. The JVM checks for this interface at runtime to enable serialization, but there's no requirement to override any methods. The statement claiming it has two methods that must be overridden is false.
B
Correct answer
Explanation
The .NET Framework class library is divided into the Base Class Library (BCL), which provides fundamental types, and the Framework Class Library (FCL), which builds on the BCL with domain-specific namespaces. 'Basic Class Library' is not the correct terminology.