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
  1. Join dependency

  2. Transitive dependency

  3. Multivalued dependency

  4. None of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Relation is same as in BCNF but additionally, it has more than one multivalued dependencies.

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is the correct answer, there are 4 constructors of HashSet. These are :-HashSet()HashSet(c : Collection)HashSet(initialCapacity : int)HashSet(initialCapacity : int , loadFactor : float). So, this is correct answer.

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is the correct answer, there are 4 constructors of TreeSet. These are :-TreeSet()TreeSet(c : Collection)TreeSet(c : Comparator)TreeSet(s : SortedSet ). So, this is correct answer.

Multiple choice
  1. It defines the interoperability of the languages.

  2. It also specifies the rules for type visibility and access to the members of a type.

  3. It defines the inheritance and virtual methods.

  4. It establishes a framework that helps enable cross-language integration, type safety, and high performance code execution.

  5. It defines the execution environment to the code.

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

CTS does not provide execution environment.

Multiple choice
  1. These store the memory address values in the heap.

  2. These types have self describing types.

  3. These directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure.

  4. These types can be built-in (implemented by the runtime), user-defined, or enumerations.

  5. Options 1 and 2

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

Yes this is the correct answer.

Multiple choice
  1. The classes in .Net are organised in a hierarchy of namespaces.

  2. The database specific page can be accessed from the classes of such namespace.

  3. Importing the namespace is necessary to use the class.

  4. Options 1 and 2

  5. All of these

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Yes, they are correct, but option 3 is also correct.

Multiple choice
  1. A new colour will be created.

  2. runtime Exception

  3. Parameters are not enough

  4. Compile time error; cannot find method colour.

  5. Compile time error; colour is Abstract cannot create an object.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is the correct answer because colour constructor creates a new colour, but it takes parameters in the range 0-255. But, here the value passed is 284(in first parameter). So, a runtime exception named “IllegalArgumentException” will be thrown by the JVM. Hence, this is the correct answer.

Multiple choice
  1. 4

  2. 3

  3. 2

  4. 1

  5. None of these

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

 
This is correct The constructor of the Font class takes three parameters :- First parameter is of String type, which specifies the name of the Font. Second parameter is of type int, which specifies the style of the font like Font.BOLD. Third parameter is of type int, which specifies the size of the font. Example, Font f1 = new Font(“Serif”, Font.BOLD, 32); So this option is true.