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
D
Correct answer
Explanation
Integer is a wrapper class in the java.lang package that corresponds to the primitive type int. The other options are either primitive types or incorrect class names.
C
Correct answer
Explanation
The super keyword is used in Java to refer to the immediate parent class object, allowing access to its members.
-
boolean.class
-
Boolean.type
-
boolean.Class
-
Boolean.Class
A
Correct answer
Explanation
The class literal for the primitive type boolean is boolean.class.
-
boolean.class
-
Boolean.type
-
boolean.Class
-
Boolean.Class
B
Correct answer
Explanation
Boolean.TYPE is the Class object representing the primitive type boolean.
-
Integer.Type
-
integer.type
-
integer.class
-
Integer.class
A
Correct answer
Explanation
Integer.TYPE is the Class object representing the primitive type int.
-
short.class
-
Short.Class
-
short.Class
-
short.Class
A
Correct answer
Explanation
The class literal for the primitive type short is short.class.
-
Join dependency
-
Transitive dependency
-
Multivalued dependency
-
None of these
C
Correct answer
Explanation
Relation is same as in BCNF but additionally, it has more than one multivalued dependencies.
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.
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.
-
It defines the interoperability of the languages.
-
It also specifies the rules for type visibility and access to the members of a type.
-
It defines the inheritance and virtual methods.
-
It establishes a framework that helps enable cross-language integration, type safety, and high performance code execution.
-
It defines the execution environment to the code.
E
Correct answer
Explanation
CTS does not provide execution environment.
-
These store the memory address values in the heap.
-
These types have self describing types.
-
These directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure.
-
These types can be built-in (implemented by the runtime), user-defined, or enumerations.
-
Options 1 and 2
E
Correct answer
Explanation
Yes this is the correct answer.
-
The classes in .Net are organised in a hierarchy of namespaces.
-
The database specific page can be accessed from the classes of such namespace.
-
Importing the namespace is necessary to use the class.
-
Options 1 and 2
-
All of these
D
Correct answer
Explanation
Yes, they are correct, but option 3 is also correct.
C
Correct answer
Explanation
There are 8 primitive data types in java. These are:-ByteShortIntLongDoubleCharFloatBoolean. So, this is correct answer.
-
A new colour will be created.
-
runtime Exception
-
Parameters are not enough
-
Compile time error; cannot find method colour.
-
Compile time error; colour is Abstract cannot create an object.
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.
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.