☑ MCQ PRACTICE

Object Oriented Programming through Java Unit 2

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

📚 Object Oriented Programming through Java
📖 Unit 2
🎯 MCQs

Object Oriented Programming through Java - Unit-2

1
___ is the superclass to all Java classes either user-defined or built-in.
AClass
BObject
CSuperclass
DNull
Correct Answer Object
2
Java language doesn't supports ___ type of inheritance.
AMultiple Inheritance
BMulti-Level Inheritance
CSingle Inheritance
DHierarchical Inheritance
Correct Answer Multiple Inheritance
3
which access modifier data members will be accessible Inside the package only.
Apublic
Bdefault
Cprivate
Dprotected
Correct Answer default
4
which access modifier data members will be accessible Inside the package and outside the package through sub classes.
Apublic
Bdefault
Cprivate
Dprotected
Correct Answer protected
5
which access modifier data members will be accessible Inside the class only.
Apublic
Bdefault
Cprivate
Dprotected
Correct Answer private
6
Which of the method is not supported by scanner class?
AnextLine()
BreadLine()
CnextInt()
DNone of the above
Correct Answer readLine()
7
What is the correct syntax to create to an object for Console class?
AConsole c = new Console();
BConsole c = new Console(System.in);
CConsole c = System.console();
DNone of above
Correct Answer Console c = System.console();
8
Constructor is a special type of method which is used to ______________________?
Ainitialize the object
Bprovide default values to an object
Cprovide different values to distinct objects
DAll the above
Correct Answer All the above
9
Which of the following is not a standard rule to define constructor?
AConstructor name must be same as it's Class name
BConstructor must have explict return type
CConstructor must have no explict return type
DNone of the above
Correct Answer Constructor must have explict return type
10
The wrapping up of data and functions into a single unit is called
AEncapsulation
BAbstraction
CData Hiding
DPolymorphism
Correct Answer Encapsulation
11
In object-oriented programming, new classes can be defined by extending existing classes. This is an example of:
AEncapsulation
BInterface
CComposition
DInheritance
Correct Answer Inheritance
12
What is the maximum number of ELSE-IF statements that can present in between starting IF and ending ELSE statements?
A32
B64
C128
DNone
Correct Answer None
13
The super keyword is used to ____________________.
Aaccess the variables in parent class
Baccess the variables in child class
Caccess the methods in parent class
Daccess the variables and methods in parent class
Correct Answer access the variables and methods in parent class
14
Which of the following statement is invalid about final keyword?
AThe final keyword can be appiled on classes to prevent inheritance
BThe final keyword can be appiled on methods to disallow method overridding
CThe final keyword can be appiled on methods to disallow method overloading
DThe final keyword can be appiled on variables to declare constants
Correct Answer The final keyword can be appiled on methods to disallow method overloading
15
The compile time polymorphism performed by _______________________?
Amethod overloading
Bmethod overriding
Cboth method overloading and overriding
Dnone of the above
Correct Answer method overloading
16
If a class have multiple methods with same name but different parameters is known as _________________?
Amethod overloading
Bmethod overriding
Cconstructor overloading
Dnone of the above
Correct Answer method overloading
17
If a child class has the same method as declared in the parent class is known as _________________?
Amethod overloading
Bmethod overriding
Cconstructor overloading
Dnone of the above
Correct Answer method overriding
18
which of the following is not a rule for method overriding?
AMethods must have same name
BMethods must have same method parameters
CIS-A relationship between child and parent class
DClass name and method name must be same.
Correct Answer Class name and method name must be same.
19
To stop or block inheriting a given class, the ___ keyword is used before the class.
Astatic
Bprivate
Cfinal
Dnone of the above
Correct Answer final
20
An Overridden method is the method of ____ class and the overriding method is the method of ___ class.
Asuper, sub
Bsub, super
Csuper, super
Dsub, sub
Correct Answer super, sub
21
___________ binding will be performed at runtime when we override the methods.
ADynamic
BStatic
CBoth
DNone of the above
Correct Answer Dynamic
22
If you import "packagename.classname" then ___________ of this package will be accessible.
Aall the classes
Bsome of the classes
Conly specified class
Dall the classes and interfaces
Correct Answer only specified class

Fill in the Blanks

23 An abstract class can have abstract and non abstract methods. (True / False)
Correct Answer True
24 In a Multi Level Inheritance Class-C inherits from Class-B and Class-B inherits from Class-State TRUE or FALSE.
Correct Answer TRUE
25 If you use "packagename.*" then all the classes and interfaces of this package and subpackages will be accessible.
Correct Answer False
← Back to All MCQs