SlideShare a Scribd company logo
1 of 45
Download to read offline
MCQs BANK
Page: 1
Object Oriented
Programming
Topic: Interfaces
Instructions:
This MCQs Bank contains question
and solution on adjacent(even-odd)
pages. First try to solve the MCQ by
yourself, then look for the solution.
Best viewed in “single page view”
in PDF viewer.
MCQs BANK No.: 8
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 1
In interfaces, none of the methods
are implemented. True or False
a) True
b) False
Page: 2
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 1 (Solution)
Ans: a) True
Explanation:
Interfaces are similar to abstract
classes, but differ in their
functionality. In interfaces, none of
the methods are implemented
means interfaces defines methods
without body.
Interfaces are syntactically similar
to classes, but they lack instance
variables, and their methods are
declared without any body.
Page: 3
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 2
What is an interface?
a) An interface is a collection of
constants and method
declarations.
b) An interface is a class that a
child class can extend.
c) An interface is a collection of
GUI components.
d) An interface is the collection of
public methods of a class.
Page: 4
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 2 (Solution)
Ans: a) An interface is a collection
of constants and method
declarations.
Explanation: An interface is a
collection of constants and method
declarations.
Interfaces are similar to abstract
classes, but differ in their
functionality. In interfaces, none of
the methods are implemented
means interfaces defines methods
without body.
Page: 5
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 3
Can an interface ever contain
method bodies?
a) No
b) Yes.
c) Sometimes.
d) Always.
Page: 6
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 3 (Solution)
Ans: a) No
Explanation:
An interface is the collection of
public methods of a class.
Page: 7
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 4
Interfaces can contain final
variables, which must be initialized
with values. True or False
a) True
b) False
Page: 8
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 4 (Solution)
Ans: a) True
Explanation:
Interfaces are syntactically similar
to classes, but they lack instance
variables, and their methods are
declared without any body. But, it
can contain final variables, which
must be initialized with values.
Once it is defined, any number of
classes can implement an
interface.
Page: 9
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 5
One class can implement
____________ interfaces. Fill in
the blank.
a) only one
b) any number of
c) upto 3
d) upto 2
Page: 10
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 5 (Solution)
Ans: b) any number of
Explanation:
One class can implement any
number of interfaces. If we are
implementing an interface in a class
we must implement all the methods
defined in the interface as well as a
class can also implement its own
methods.
Page: 11
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 6
Any class that includes an
interface must implement all of the
methods. True or False
a) True
b) False
Page: 12
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 6 (Solution)
Ans: a) True
Explanation: Yes, it is mandatory to
implement all the methods in a class that
implements an interface until and unless
that class is declared as an abstract
class. Implemention every method
defined by the interface is mandatory.
When a class implements an interface, it
is essentially signing a contract. Either
the class must implement all the
methods declared in the interface and its
superinterfaces, or the class must be
declared abstract. The method signature
— the name and the number and type of
arguments — in the class must match
the method signature as it appears in the
interface.
Page: 13
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 7
Variables declaed inside interfaces
are implicitly final and static. True or
False
a) True
b) False
Page: 14
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 7 (Solution)
Ans: a) True
Explanation:
Variables can be declared inside
interface declarations. They are implicitly
final and static, means they can not be
changed by implementing it in a class.
Interface variables are static because
java interfaces cannot be instantiated on
their own. The value of the variable must
be assigned in a static context in which
no instance exists.
The final modifier ensures the value
assigned to the interface variable is a
true constant that cannot be re-assigned.
In other words, interfaces can declare
only constants, not instance variables.
Page: 15
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 8
To implement an interface, include
the _________ keyword in a class
definition, and then create the
methods
declared by the interface. Fill in the
blank.
a) extends
b) implements
c) import
d) default
Page: 16
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 8 (Solution)
Ans: b) implements
Explanation:
Once an interface has been defined,
one or more classes can implement
that interface.
To implement an interface, include
the implements clause in a class
definition, and then create the
methods declared by the interface.
Page: 17
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 9
If a class implements from more
than one interface, names are
separated by _______. Fill in the
blank.
a) underscore
b) semicolon
c) comma
d) white space
Page: 18
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 9 (Solution)
Ans: c) comma
Explanation: If a class implements
from more than one interface, names
are separated by comma. Your class
can implement more than one
interface (the Java platform supports
multiple inheritance for interfaces),
so the implements keyword is
followed by a comma-separated list
of the interfaces implemented by the
class.
Page: 19
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 10
The methods that implement an
interface must be declared as
________. Fill in the blank.
a) private
b) public
c) protected
d) any one of the above
Page: 20
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 10 (Solution)
Ans: b) public
Explanation: The methods that
implement an interface must be declared
as public. The type-signature of
implementing method must match exactly
the type signature specified in the
interface. The class that implements the
interface must declare the methods are
public so that the instances of the class
can access them, if those methods are
defined with some different access
specifier then the instances of the class
are able to access those methods. It is
possible for classes that implement
interfaces to define additional members of
their own.
Page: 21
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 11
If a class implements an interface
but does not fully implement the
method defined by that interface,
then that class must be declared
as ____________ . Fill in the
blank.
a) interface
b) abstract
c) static
d) final
Page: 22
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 11 (Solution)
Ans: b) abstract
Explanation:
If a class implements an interface
but does not fully implement the
method defined by that interface,
then that class must be declared as
abstract. Partial Implementation of
Interface is allowed only if the class
is declared as abstract. If we want to
implement an interface in a class we
have to implement all the methods
defined in the interface.
Page: 23
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 12
One can declare variable as object
references that uses an interface
rather than a class type. True or
False
a) True
b) False
Page: 24
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 12 (Solution)
Ans: a) True
Explanation:
One can declare variable as object
references that uses an interface rather
than a class type.
When you call a method through one of
these references, the correct version will
be called based on the actual instance of
the interface being referred to. When you
define a new interface, you are defining a
new reference data type. You can use
interface names anywhere you can use
any other data type name. If you define a
reference variable whose type is an
interface, any object you assign to it must
be an instance of a class that implements
the interface.
Page: 25
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 13
When a class implements an
interface that inherits another
interface, it must provide
implementation of all methods
defined within the interface
inheritance. True or False
a) True
b) False
Page: 26
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 13 (Solution)
Ans: a) True
Explanation:
Any class that implements an
interface must implement all
methods defined by that interface,
including any that inherited from
other interfaces.
Page: 27
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 14
When a class implements an
interface, what must it do?
a) It must redefine each constant
from the interface.
b) It must declare and provide a
method body for each method in
the interface.
c) It must declare a variable for
each constant in the interface.
d) It must include a private method
for each method in the interface.
Page: 28
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 14 (Solution)
Ans: b) It must declare and provide
a method body for each method in
the interface.
Explanation: When a class
implements an interfaces, it must
declare and provide a method body
for each method in the interface.
Page: 29
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 15
Which of the following is true?
a) A child class can extend a
parent or implement an interface,
but not do both.
b) A child class can extend just one
parent and can implement just one
interface.
c) A child class can extend just one
parent and can implement zero or
more interfaces.
d) A child class can extend zero or
more parents, and can implement
zero or more interfaces.
Page: 30
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 15 (Solution)
Ans: c) A child class can extend just
one parent and can implement zero
or more interfaces.
Explanation:
In Java, (unlike with humans)
children inherit characteristics from
just one parent. This is called single
inheritance. Java does not support
"multiple inheritance" (a class can
only inherit from one superclass).
However, it can be achieved with
interfaces, because the class can
implement multiple interfaces. Note:
To implement multiple interfaces,
separate them with a comma.
Page: 31
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 16
Is the following a correct way to
start out a class definition:
public class SomeClass
implements MyInterface
a) No---SomeClass must also
extend a base class.
b) No---SomeClass cannot be
public if it implements an interface
c) Yes--SomeClass is a child of
MyInterface
d) Yes--SomeClass is
automatically a child of the class
Object.
Page: 32
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 16 (Solution)
Ans: d) Yes--SomeClass is
automatically a child of the class
Object.
Explanation:
In the absence of any other explicit
superclass, every class is implicitly a
subclass of Object . Classes can be
derived from classes that are derived
from classes that are derived from
classes, and so on, and ultimately
derived from the topmost class,
Object.
Page: 33
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 17
Look at the following interface
interface Taxable { double taxRate =
0.06; double calculateTax(); }
Is the interface correct?
a) No---because it contains a variable
and interfaces cannot contain
variables.
b) No---because the interface cannot
contain a method that returns a value.
c) Yes--taxRate will automatically be a
constant since it is in an interface.
d) Yes--the method body will
automatically be filled in.
Page: 34
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 17 (Solution)
Ans: c) Yes--taxRate will
automatically be a constant since it
is in an interface.
Explanation:
Interface variables are static
because java interfaces cannot be
instantiated on their own. The value
of the variable must be assigned in a
static context in which no instance
exists. The final modifier ensures the
value assigned to the interface
variable is a true constant that
cannot be re-assigned.
Page: 35
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 18
Can an interface name be used as
the type of a variable, like this:
public static void main( String[]
args ) { SomeInterface x; ... }
a) No---a variable must always be
an object reference type.
b) No---a variable must always be
an object reference type or a
primitive type.
c) No---a variable must always be
a primitive type.
d) Yes--the variable can refer to
any object who's class implements
the interface.
Page: 36
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 18 (Solution)
Ans: d) Yes--the variable can refer
to any object who's class implements
the interface.
Explanation: None
Page: 37
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 19
Is it OK if a class definition
implements two interfaces, each of
which has the same definition for
the constant PI?
a) No---if a class implements
several interfaces, each constant
must be defined in only one
interface.
b) No---a class may not implement
more than one interface.
c) Yes--since the definitions are the
same it will not matter.
d) Yes--the more accurate
definition of the two will override
the other.
Page: 38
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 19 (Solution)
Ans: a) No---if a class implements
several interfaces, each constant
must be defined in only one interface.
Explanation: None
Page: 39
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 20
Can an interface be given the
private access modifier?
a) No---then the interface could
never be used.
b) No---since only private classes
could use the interface.
c) Yes--this would make all of its
methods and constants private.
d) Yes--this would mean that only
classes in the same file could use
the interface.
Page: 40
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 20 (Solution)
Ans: a) No---then the interface could
never be used.
Explanation: None
Page: 41
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 21
Can an interface extend another
interface?
a) No---only classes can be
extended.
b) No---interfaces can not be part
of a hierarchy.
c) Yes--since all interfaces
automatically extend Object.
d) Yes.
Page: 42
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 21 (Solution)
Ans: d) Yes.
Explanation: None
Page: 43
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 22
Which of the following is the
correct way of implementing an
interface salary by class manager?
a) class manager extends salary {}
b) class manager implements
salary {}
c) class manager imports salary {}
d) none of the mentioned
Page: 44
MCQs Bank on Object Oriented Programming
Topic : Interfaces
MCQ No: 22 (Solution)
Ans: b) class manager implements
salary {}
Explanation:
None
Page: 45

More Related Content

What's hot

Time space trade off
Time space trade offTime space trade off
Time space trade offanisha talwar
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursionAbdullah Al-hazmy
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programmingTafhim Islam
 
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...Kuntal Bhowmick
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonSujith Kumar
 
2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factors2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factorskrishna singh
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresRecursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresPriyanka Rana
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using BacktrackingAbhishek Singh
 
Array data structure
Array data structureArray data structure
Array data structuremaamir farooq
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure shameen khan
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in PythonSujith Kumar
 
strassen matrix multiplication algorithm
strassen matrix multiplication algorithmstrassen matrix multiplication algorithm
strassen matrix multiplication algorithmevil eye
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListManishPrajapati78
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data StructureA. N. M. Jubaer
 

What's hot (20)

Time space trade off
Time space trade offTime space trade off
Time space trade off
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programming
 
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factors2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factors
 
Recursion
RecursionRecursion
Recursion
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresRecursion - Algorithms and Data Structures
Recursion - Algorithms and Data Structures
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
Heaps
HeapsHeaps
Heaps
 
Dynamic pgmming
Dynamic pgmmingDynamic pgmming
Dynamic pgmming
 
Array data structure
Array data structureArray data structure
Array data structure
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 
Binary Search
Binary SearchBinary Search
Binary Search
 
Merge sort
Merge sortMerge sort
Merge sort
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
strassen matrix multiplication algorithm
strassen matrix multiplication algorithmstrassen matrix multiplication algorithm
strassen matrix multiplication algorithm
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data Structure
 

Similar to Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- interfaces

Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...
Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...
Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...Kuntal Bhowmick
 
Abstract & Interface
Abstract & InterfaceAbstract & Interface
Abstract & InterfaceLinh Lê
 
Oop r&s may 2019 (2)
Oop r&s may 2019 (2)Oop r&s may 2019 (2)
Oop r&s may 2019 (2)ktuonlinenotes
 
21: Which method determines if a JRadioButton is selected?
21: Which method determines if a JRadioButton is selected?21: Which method determines if a JRadioButton is selected?
21: Which method determines if a JRadioButton is selected?sukeshsuresh189
 
Comp 328 final guide (devry)
Comp 328 final guide (devry)Comp 328 final guide (devry)
Comp 328 final guide (devry)sukeshsuresh189
 
6: Which of the following statements about creating arrays and initializing t...
6: Which of the following statements about creating arrays and initializing t...6: Which of the following statements about creating arrays and initializing t...
6: Which of the following statements about creating arrays and initializing t...sukeshsuresh189
 
202: When the user clicks a JCheckBox, a(n) occurs.
202: When the user clicks a JCheckBox, a(n) occurs.202: When the user clicks a JCheckBox, a(n) occurs.
202: When the user clicks a JCheckBox, a(n) occurs.sukeshsuresh189
 
3: A(n) ________ enables a program to read data from the user.
3: A(n) ________ enables a program to read data from the user.3: A(n) ________ enables a program to read data from the user.
3: A(n) ________ enables a program to read data from the user.sukeshsuresh189
 
22: The logical relationship between radio buttons is maintained by objects o...
22: The logical relationship between radio buttons is maintained by objects o...22: The logical relationship between radio buttons is maintained by objects o...
22: The logical relationship between radio buttons is maintained by objects o...sukeshsuresh189
 
19: When the user presses Enter in a JTextField, the GUI component generates ...
19: When the user presses Enter in a JTextField, the GUI component generates ...19: When the user presses Enter in a JTextField, the GUI component generates ...
19: When the user presses Enter in a JTextField, the GUI component generates ...sukeshsuresh189
 
12: When an object is concatenated with a String
12: When an object is concatenated with a String12: When an object is concatenated with a String
12: When an object is concatenated with a Stringsukeshsuresh189
 
5: Every Java application is required to have
5: Every Java application is required to have5: Every Java application is required to have
5: Every Java application is required to havesukeshsuresh189
 
15: Which method call converts the value in variable stringVariable to an int...
15: Which method call converts the value in variable stringVariable to an int...15: Which method call converts the value in variable stringVariable to an int...
15: Which method call converts the value in variable stringVariable to an int...sukeshsuresh189
 
16: Which of the following is the method used to display a dialog box to gath...
16: Which of the following is the method used to display a dialog box to gath...16: Which of the following is the method used to display a dialog box to gath...
16: Which of the following is the method used to display a dialog box to gath...sukeshsuresh189
 
13: What do the following statements do?
13: What do the following statements do?13: What do the following statements do?
13: What do the following statements do?sukeshsuresh189
 

Similar to Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- interfaces (20)

Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
 
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
 
Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...
Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...
Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...
 
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
 
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
 
Abstract & Interface
Abstract & InterfaceAbstract & Interface
Abstract & Interface
 
Introduction of C# & MVC
Introduction of C# & MVCIntroduction of C# & MVC
Introduction of C# & MVC
 
Oop r&s may 2019 (2)
Oop r&s may 2019 (2)Oop r&s may 2019 (2)
Oop r&s may 2019 (2)
 
21: Which method determines if a JRadioButton is selected?
21: Which method determines if a JRadioButton is selected?21: Which method determines if a JRadioButton is selected?
21: Which method determines if a JRadioButton is selected?
 
Comp 328 final guide (devry)
Comp 328 final guide (devry)Comp 328 final guide (devry)
Comp 328 final guide (devry)
 
6: Which of the following statements about creating arrays and initializing t...
6: Which of the following statements about creating arrays and initializing t...6: Which of the following statements about creating arrays and initializing t...
6: Which of the following statements about creating arrays and initializing t...
 
202: When the user clicks a JCheckBox, a(n) occurs.
202: When the user clicks a JCheckBox, a(n) occurs.202: When the user clicks a JCheckBox, a(n) occurs.
202: When the user clicks a JCheckBox, a(n) occurs.
 
3: A(n) ________ enables a program to read data from the user.
3: A(n) ________ enables a program to read data from the user.3: A(n) ________ enables a program to read data from the user.
3: A(n) ________ enables a program to read data from the user.
 
22: The logical relationship between radio buttons is maintained by objects o...
22: The logical relationship between radio buttons is maintained by objects o...22: The logical relationship between radio buttons is maintained by objects o...
22: The logical relationship between radio buttons is maintained by objects o...
 
19: When the user presses Enter in a JTextField, the GUI component generates ...
19: When the user presses Enter in a JTextField, the GUI component generates ...19: When the user presses Enter in a JTextField, the GUI component generates ...
19: When the user presses Enter in a JTextField, the GUI component generates ...
 
12: When an object is concatenated with a String
12: When an object is concatenated with a String12: When an object is concatenated with a String
12: When an object is concatenated with a String
 
5: Every Java application is required to have
5: Every Java application is required to have5: Every Java application is required to have
5: Every Java application is required to have
 
15: Which method call converts the value in variable stringVariable to an int...
15: Which method call converts the value in variable stringVariable to an int...15: Which method call converts the value in variable stringVariable to an int...
15: Which method call converts the value in variable stringVariable to an int...
 
16: Which of the following is the method used to display a dialog box to gath...
16: Which of the following is the method used to display a dialog box to gath...16: Which of the following is the method used to display a dialog box to gath...
16: Which of the following is the method used to display a dialog box to gath...
 
13: What do the following statements do?
13: What do the following statements do?13: What do the following statements do?
13: What do the following statements do?
 

More from Kuntal Bhowmick

Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loopsMultiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loopsKuntal Bhowmick
 
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Hashing notes data structures (HASHING AND HASH FUNCTIONS)Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Hashing notes data structures (HASHING AND HASH FUNCTIONS)Kuntal Bhowmick
 
1. introduction to E-commerce
1. introduction to E-commerce1. introduction to E-commerce
1. introduction to E-commerceKuntal Bhowmick
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solvedKuntal Bhowmick
 
DBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental conceptsDBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental conceptsKuntal Bhowmick
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interviewKuntal Bhowmick
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview QuestionsKuntal Bhowmick
 
Operating system Interview Questions
Operating system Interview QuestionsOperating system Interview Questions
Operating system Interview QuestionsKuntal Bhowmick
 
Computer Network Interview Questions
Computer Network Interview QuestionsComputer Network Interview Questions
Computer Network Interview QuestionsKuntal Bhowmick
 
Distributed operating systems cs704 a class test
Distributed operating systems cs704 a class testDistributed operating systems cs704 a class test
Distributed operating systems cs704 a class testKuntal Bhowmick
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solutionKuntal Bhowmick
 
CS291(C Programming) assignment
CS291(C Programming) assignmentCS291(C Programming) assignment
CS291(C Programming) assignmentKuntal Bhowmick
 
Shell script assignment 3
Shell script assignment 3Shell script assignment 3
Shell script assignment 3Kuntal Bhowmick
 
Basic shell programs assignment 1
Basic shell programs assignment 1Basic shell programs assignment 1
Basic shell programs assignment 1Kuntal Bhowmick
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualKuntal Bhowmick
 
Shell programming assignment 2
Shell programming assignment 2Shell programming assignment 2
Shell programming assignment 2Kuntal Bhowmick
 

More from Kuntal Bhowmick (20)

Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loopsMultiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
 
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Hashing notes data structures (HASHING AND HASH FUNCTIONS)Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
 
1. introduction to E-commerce
1. introduction to E-commerce1. introduction to E-commerce
1. introduction to E-commerce
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
 
DBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental conceptsDBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental concepts
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
 
Operating system Interview Questions
Operating system Interview QuestionsOperating system Interview Questions
Operating system Interview Questions
 
Computer Network Interview Questions
Computer Network Interview QuestionsComputer Network Interview Questions
Computer Network Interview Questions
 
C interview questions
C interview  questionsC interview  questions
C interview questions
 
C question
C questionC question
C question
 
Distributed operating systems cs704 a class test
Distributed operating systems cs704 a class testDistributed operating systems cs704 a class test
Distributed operating systems cs704 a class test
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
 
CS291(C Programming) assignment
CS291(C Programming) assignmentCS291(C Programming) assignment
CS291(C Programming) assignment
 
C programming guide new
C programming guide newC programming guide new
C programming guide new
 
C lecture notes new
C lecture notes newC lecture notes new
C lecture notes new
 
Shell script assignment 3
Shell script assignment 3Shell script assignment 3
Shell script assignment 3
 
Basic shell programs assignment 1
Basic shell programs assignment 1Basic shell programs assignment 1
Basic shell programs assignment 1
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
 
Shell programming assignment 2
Shell programming assignment 2Shell programming assignment 2
Shell programming assignment 2
 

Recently uploaded

HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxkalpana413121
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxpritamlangde
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Ramkumar k
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxNANDHAKUMARA10
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfsumitt6_25730773
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementDr. Deepak Mudgal
 
Introduction to Geographic Information Systems
Introduction to Geographic Information SystemsIntroduction to Geographic Information Systems
Introduction to Geographic Information SystemsAnge Felix NSANZIYERA
 
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...ssuserdfc773
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesRashidFaridChishti
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
Query optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsQuery optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsmeharikiros2
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxMustafa Ahmed
 

Recently uploaded (20)

HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth Reinforcement
 
Introduction to Geographic Information Systems
Introduction to Geographic Information SystemsIntroduction to Geographic Information Systems
Introduction to Geographic Information Systems
 
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Query optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsQuery optimization and processing for advanced database systems
Query optimization and processing for advanced database systems
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 

Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- interfaces

  • 1. MCQs BANK Page: 1 Object Oriented Programming Topic: Interfaces Instructions: This MCQs Bank contains question and solution on adjacent(even-odd) pages. First try to solve the MCQ by yourself, then look for the solution. Best viewed in “single page view” in PDF viewer. MCQs BANK No.: 8
  • 2. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 1 In interfaces, none of the methods are implemented. True or False a) True b) False Page: 2
  • 3. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 1 (Solution) Ans: a) True Explanation: Interfaces are similar to abstract classes, but differ in their functionality. In interfaces, none of the methods are implemented means interfaces defines methods without body. Interfaces are syntactically similar to classes, but they lack instance variables, and their methods are declared without any body. Page: 3
  • 4. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 2 What is an interface? a) An interface is a collection of constants and method declarations. b) An interface is a class that a child class can extend. c) An interface is a collection of GUI components. d) An interface is the collection of public methods of a class. Page: 4
  • 5. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 2 (Solution) Ans: a) An interface is a collection of constants and method declarations. Explanation: An interface is a collection of constants and method declarations. Interfaces are similar to abstract classes, but differ in their functionality. In interfaces, none of the methods are implemented means interfaces defines methods without body. Page: 5
  • 6. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 3 Can an interface ever contain method bodies? a) No b) Yes. c) Sometimes. d) Always. Page: 6
  • 7. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 3 (Solution) Ans: a) No Explanation: An interface is the collection of public methods of a class. Page: 7
  • 8. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 4 Interfaces can contain final variables, which must be initialized with values. True or False a) True b) False Page: 8
  • 9. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 4 (Solution) Ans: a) True Explanation: Interfaces are syntactically similar to classes, but they lack instance variables, and their methods are declared without any body. But, it can contain final variables, which must be initialized with values. Once it is defined, any number of classes can implement an interface. Page: 9
  • 10. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 5 One class can implement ____________ interfaces. Fill in the blank. a) only one b) any number of c) upto 3 d) upto 2 Page: 10
  • 11. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 5 (Solution) Ans: b) any number of Explanation: One class can implement any number of interfaces. If we are implementing an interface in a class we must implement all the methods defined in the interface as well as a class can also implement its own methods. Page: 11
  • 12. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 6 Any class that includes an interface must implement all of the methods. True or False a) True b) False Page: 12
  • 13. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 6 (Solution) Ans: a) True Explanation: Yes, it is mandatory to implement all the methods in a class that implements an interface until and unless that class is declared as an abstract class. Implemention every method defined by the interface is mandatory. When a class implements an interface, it is essentially signing a contract. Either the class must implement all the methods declared in the interface and its superinterfaces, or the class must be declared abstract. The method signature — the name and the number and type of arguments — in the class must match the method signature as it appears in the interface. Page: 13
  • 14. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 7 Variables declaed inside interfaces are implicitly final and static. True or False a) True b) False Page: 14
  • 15. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 7 (Solution) Ans: a) True Explanation: Variables can be declared inside interface declarations. They are implicitly final and static, means they can not be changed by implementing it in a class. Interface variables are static because java interfaces cannot be instantiated on their own. The value of the variable must be assigned in a static context in which no instance exists. The final modifier ensures the value assigned to the interface variable is a true constant that cannot be re-assigned. In other words, interfaces can declare only constants, not instance variables. Page: 15
  • 16. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 8 To implement an interface, include the _________ keyword in a class definition, and then create the methods declared by the interface. Fill in the blank. a) extends b) implements c) import d) default Page: 16
  • 17. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 8 (Solution) Ans: b) implements Explanation: Once an interface has been defined, one or more classes can implement that interface. To implement an interface, include the implements clause in a class definition, and then create the methods declared by the interface. Page: 17
  • 18. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 9 If a class implements from more than one interface, names are separated by _______. Fill in the blank. a) underscore b) semicolon c) comma d) white space Page: 18
  • 19. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 9 (Solution) Ans: c) comma Explanation: If a class implements from more than one interface, names are separated by comma. Your class can implement more than one interface (the Java platform supports multiple inheritance for interfaces), so the implements keyword is followed by a comma-separated list of the interfaces implemented by the class. Page: 19
  • 20. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 10 The methods that implement an interface must be declared as ________. Fill in the blank. a) private b) public c) protected d) any one of the above Page: 20
  • 21. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 10 (Solution) Ans: b) public Explanation: The methods that implement an interface must be declared as public. The type-signature of implementing method must match exactly the type signature specified in the interface. The class that implements the interface must declare the methods are public so that the instances of the class can access them, if those methods are defined with some different access specifier then the instances of the class are able to access those methods. It is possible for classes that implement interfaces to define additional members of their own. Page: 21
  • 22. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 11 If a class implements an interface but does not fully implement the method defined by that interface, then that class must be declared as ____________ . Fill in the blank. a) interface b) abstract c) static d) final Page: 22
  • 23. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 11 (Solution) Ans: b) abstract Explanation: If a class implements an interface but does not fully implement the method defined by that interface, then that class must be declared as abstract. Partial Implementation of Interface is allowed only if the class is declared as abstract. If we want to implement an interface in a class we have to implement all the methods defined in the interface. Page: 23
  • 24. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 12 One can declare variable as object references that uses an interface rather than a class type. True or False a) True b) False Page: 24
  • 25. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 12 (Solution) Ans: a) True Explanation: One can declare variable as object references that uses an interface rather than a class type. When you call a method through one of these references, the correct version will be called based on the actual instance of the interface being referred to. When you define a new interface, you are defining a new reference data type. You can use interface names anywhere you can use any other data type name. If you define a reference variable whose type is an interface, any object you assign to it must be an instance of a class that implements the interface. Page: 25
  • 26. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 13 When a class implements an interface that inherits another interface, it must provide implementation of all methods defined within the interface inheritance. True or False a) True b) False Page: 26
  • 27. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 13 (Solution) Ans: a) True Explanation: Any class that implements an interface must implement all methods defined by that interface, including any that inherited from other interfaces. Page: 27
  • 28. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 14 When a class implements an interface, what must it do? a) It must redefine each constant from the interface. b) It must declare and provide a method body for each method in the interface. c) It must declare a variable for each constant in the interface. d) It must include a private method for each method in the interface. Page: 28
  • 29. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 14 (Solution) Ans: b) It must declare and provide a method body for each method in the interface. Explanation: When a class implements an interfaces, it must declare and provide a method body for each method in the interface. Page: 29
  • 30. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 15 Which of the following is true? a) A child class can extend a parent or implement an interface, but not do both. b) A child class can extend just one parent and can implement just one interface. c) A child class can extend just one parent and can implement zero or more interfaces. d) A child class can extend zero or more parents, and can implement zero or more interfaces. Page: 30
  • 31. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 15 (Solution) Ans: c) A child class can extend just one parent and can implement zero or more interfaces. Explanation: In Java, (unlike with humans) children inherit characteristics from just one parent. This is called single inheritance. Java does not support "multiple inheritance" (a class can only inherit from one superclass). However, it can be achieved with interfaces, because the class can implement multiple interfaces. Note: To implement multiple interfaces, separate them with a comma. Page: 31
  • 32. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 16 Is the following a correct way to start out a class definition: public class SomeClass implements MyInterface a) No---SomeClass must also extend a base class. b) No---SomeClass cannot be public if it implements an interface c) Yes--SomeClass is a child of MyInterface d) Yes--SomeClass is automatically a child of the class Object. Page: 32
  • 33. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 16 (Solution) Ans: d) Yes--SomeClass is automatically a child of the class Object. Explanation: In the absence of any other explicit superclass, every class is implicitly a subclass of Object . Classes can be derived from classes that are derived from classes that are derived from classes, and so on, and ultimately derived from the topmost class, Object. Page: 33
  • 34. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 17 Look at the following interface interface Taxable { double taxRate = 0.06; double calculateTax(); } Is the interface correct? a) No---because it contains a variable and interfaces cannot contain variables. b) No---because the interface cannot contain a method that returns a value. c) Yes--taxRate will automatically be a constant since it is in an interface. d) Yes--the method body will automatically be filled in. Page: 34
  • 35. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 17 (Solution) Ans: c) Yes--taxRate will automatically be a constant since it is in an interface. Explanation: Interface variables are static because java interfaces cannot be instantiated on their own. The value of the variable must be assigned in a static context in which no instance exists. The final modifier ensures the value assigned to the interface variable is a true constant that cannot be re-assigned. Page: 35
  • 36. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 18 Can an interface name be used as the type of a variable, like this: public static void main( String[] args ) { SomeInterface x; ... } a) No---a variable must always be an object reference type. b) No---a variable must always be an object reference type or a primitive type. c) No---a variable must always be a primitive type. d) Yes--the variable can refer to any object who's class implements the interface. Page: 36
  • 37. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 18 (Solution) Ans: d) Yes--the variable can refer to any object who's class implements the interface. Explanation: None Page: 37
  • 38. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 19 Is it OK if a class definition implements two interfaces, each of which has the same definition for the constant PI? a) No---if a class implements several interfaces, each constant must be defined in only one interface. b) No---a class may not implement more than one interface. c) Yes--since the definitions are the same it will not matter. d) Yes--the more accurate definition of the two will override the other. Page: 38
  • 39. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 19 (Solution) Ans: a) No---if a class implements several interfaces, each constant must be defined in only one interface. Explanation: None Page: 39
  • 40. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 20 Can an interface be given the private access modifier? a) No---then the interface could never be used. b) No---since only private classes could use the interface. c) Yes--this would make all of its methods and constants private. d) Yes--this would mean that only classes in the same file could use the interface. Page: 40
  • 41. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 20 (Solution) Ans: a) No---then the interface could never be used. Explanation: None Page: 41
  • 42. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 21 Can an interface extend another interface? a) No---only classes can be extended. b) No---interfaces can not be part of a hierarchy. c) Yes--since all interfaces automatically extend Object. d) Yes. Page: 42
  • 43. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 21 (Solution) Ans: d) Yes. Explanation: None Page: 43
  • 44. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 22 Which of the following is the correct way of implementing an interface salary by class manager? a) class manager extends salary {} b) class manager implements salary {} c) class manager imports salary {} d) none of the mentioned Page: 44
  • 45. MCQs Bank on Object Oriented Programming Topic : Interfaces MCQ No: 22 (Solution) Ans: b) class manager implements salary {} Explanation: None Page: 45