☑ MCQ PRACTICE

Java Programming Part 2

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

📚 Java Programming
📖 Part 2
🎯 MCQs

Java Programming - Part-2

1
Java method overloading implements the OOPS concept ___.
AInheritance
BPolymorphism
CEncapsulation
DNone
Correct Answer Polymorphism
2
___ is the superclass to all Java classes either user-defined or built-in.
AClass
BObject
CSuperclass
DNull
Correct Answer Object
3
Java language doesn't supports ___ type of inheritance.
AMultiple Inheritance
BMulti-Level Inheritance
CSingle Inheritance
DHierarchical Inheritance
Correct Answer Multiple Inheritance
4
If you use "import packagename.* ", which of the following will be accessible.
AAll the classes and interfaces of this package and subpackages
BAll the classes and interfaces of this package
COnly classes of this package
DNone
Correct Answer All the classes and interfaces of this package
5
Which access modifier data members will be accessible Inside the package only.
Apublic
Bdefault
Cprivate
Dprotected
Correct Answer default
6
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
7
Which access modifier data members will be accessible Inside the class only.
Apublic
Bdefault
Cprivate
Dprotected
Correct Answer private
8
Which of the method is not supported by scanner class?
AnextLine()
BreadLine()
CnextInt()
DNone of the above
Correct Answer readLine()
9
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();
10
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
11
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
12
The wrapping up of data and functions into a single unit is called
AEncapsulation
BAbstraction
CData Hiding
DPolymorphism
Correct Answer Encapsulation
13
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
14
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
15
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
16
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
17
The compile time polymorphism performed by _______________________?
Amethod overloading
Bmethod overriding
Cboth method overloading and overriding
Dnone of the above
Correct Answer method overloading
18
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
19
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
20
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.
21
For a Multi Level Inheritance which of the following is correct?
AClass-C inherits from Class-A and Class-B inherits from Class-C
BClass-C inherits from Class-A and Class-B
CClass-B inherits from Class-A and Class-B inherits from Class-A
DNone of the above
Correct Answer Class-C inherits from Class-A and Class-B inherits from Class-C
22
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
23
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
24
___________ binding will be performed at runtime when we override the methods.
ADynamic
BStatic
CBoth
DNone of the above
Correct Answer Dynamic
25
An abstract class can have __________________________?
AOnly abstract methods.
BOnly non abstract methods.
CAbstract and non abstract methods.
DNone of the above
Correct Answer Abstract and non abstract methods.
← Back to All MCQs