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

Multiple choice technology web technology
  1. only 1

  2. 2

  3. No need of void main

  4. infinite

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. Set

  2. List

  3. Map

  4. Vector

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. Interface in Java

  2. pointer in C or C++

  3. function pointer in C or C++

  4. Interface in .NET

Reveal answer Fill a bubble to check yourself
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++.

Multiple choice technology web technology
  1. private

  2. protected

  3. protected internal

  4. It is not possible to do it

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.