SlideShare a Scribd company logo
MCQs BANK
Page: 1
Object Oriented
Programming
Topic: Abstract Classes
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.: 7
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 1
When the keyword _______ appears
in a class definition, it means that
zero or more of it’s methods are
abstract.
a) abstract
b) default
c) static
d) public
Page: 2
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 1 (Solution)
Ans: a) abstract
Explanation:
When the keyword abstract
appears in a class definition, it
means that zero or more of it’s
methods are abstract.
Abstract class is a restricted class
that cannot be used to create
objects (to access it, it must be
inherited from another class).
Abstract method can only be used
in an abstract class, and it does
not have a body. The body is
provided by the subclass (inherited
from).
Page: 3
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 2
An _________ method has no
body. Fill in the blank.
a) static
b) abstract
c) private
d) public
Page: 4
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 2 (Solution)
Ans: b) abstract
Explanation: An abstract method
has no body. Some of the
subclass has to override it and
provide the implementation.
Abstract methods are declaration
only and it will not have
implementation. It will not have a
method body. A Java class
containing an abstract class must
be declared as abstract class.
Page: 5
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 3
Objects cannot be created out of
abstract class. True or False
a) True
b) False
Page: 6
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 3 (Solution)
Ans: a) True
Explanation:
Objects cannot be created out of
abstract class. Abstract classes
basically provide a guideline for the
properties and methods of an
object.
Page: 7
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 4
An abstract class, which declared
with the “abstract” keyword, cannot
be instantiated. True or False?
a) True
b) False
Page: 8
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 4 (Solution)
Ans: a) True
Explanation:
An abstract class, which declared
with the “abstract” keyword, cannot
be instantiated. This is because in
abstract class the methods are
declared only without defining
them.
Abstract classes cannot be
instantiated, but they can be sub
classed.
Page: 9
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 5
In order to use abstract classes,
they have to be ______________ .
Fill in the blank.
a) subclassed
b) sub-divided
c) overridden
d) overloaded
Page: 10
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 5 (Solution)
Ans: a) subclassed
Explanation: In order to use
abstract classes, they have to be
subclassed. There are situations in
which you want to define a
superclass that declares the
structure of a given abstraction
without providing a complete
implementation of every method.
That is, sometimes you want to
create a superclass that only defines
generalized form that will be shared
by all of its subclasses, leaving it to
each subclass to fill in the details.
Page: 11
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 6
___________ are those methods
that must be overridden by
subclasses because they have no
implementation specified in the
superclass. Fill in the blank.
a) default methods
b) abstract methods
c) static methods
d) hidden methods
Page: 12
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 6 (Solution)
Ans: b) abstract methods
Explanation:
Consider a class Triangle. It has no
meaning if area( ) is not defined. In this
case, you want some way to ensure that
a subclass does, indeed, override all
necessary methods. Java’s solution to
this problem is the abstract method. You
can require that certain methods be
overridden by subclasses by specifying
the abstract type modifier.
These methods are sometimes referred
to as subclasser responsibility because
they have no implementation specified in
the superclass. Thus, a subclass must
override them—it cannot simply use the
version defined in the superclass.
Page: 13
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 7
The correct way of declaring an
abstract method is
a) abstract return_type
method_name(parameter-list);
b) return_type
method_name(parameter-list)
abstract ;
c) return_type abstract
method_name(parameter-list);
d) all are correct
Page: 14
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 7 (Solution)
Ans: a) abstract return_type
method_name(parameter-list);
Explanation:
The correct way of declaring an
abstract method is :
abstract return_type
method_name(parameter-list);
As you can see, no method body is
present. Any class that contains one
or more abstract methods must also
be declared abstract.
Page: 15
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 8
There can be no objects of an
abstract class. True or False
a) True
b) False
Page: 16
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 8 (Solution)
Ans: a) True
Explanation:
There can be no objects of an
abstract class. That is, an abstract
class cannot be directly instantiated
with the new operator. Such objects
would be useless, because an
abstract class is not fully defined.
Page: 17
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 9
Can you declare abstract
constructors, or abstract static
methods ?
a) Yes
b) No
Page: 18
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 9 (Solution)
Ans: b) No
Explanation: You cannot declare
abstract constructors, or abstract static
methods. Constructors are invoked
automatically when objects of a class
is created using new operator. As an
abstract class cannot be directly
instantiated with the new operator so
you cannot declare abstract
constructors. static methods are class
methods, that is shared by multiple
objects(instances of the class) of a
class, as an abstract class cannot be
directly instantiated so it is not possible
to declare abstract static methods.
Page: 19
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 10
Any subclass of an abstract class
must either implement all of the
abstract methods in the superclass,
or be itself declared abstract. True or
False?
a) True
b) False
Page: 20
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 10 (Solution)
Ans: a) True
Explanation:
Any subclass of an abstract class
must either implement all of the
abstract methods in the superclass,
or be itself declared abstract.
Page: 21
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 11
Is it possible to create a reference
to an abstract class so that it can
be used to point to a subclass
object ?
a) Yes, Possible
b) No, Not Possible
Page: 22
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 11 (Solution)
Ans: a) Yes, Possible
Explanation:
Although abstract classes cannot be
used to instantiate objects, they can
be used to create object references,
because Java’s approach to run-time
polymorphism is implemented
through the use of superclass
references. Thus, it must be possible
to create a reference to an abstract
class so that it can be used to point
to a subclass object. It is through
superclass reference variables that
overridden methods are resolved at
run time.
Page: 23
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 12
Methods declared as final cannot
be overridden. True or False
a) True
b) False
Page: 24
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 12 (Solution)
Ans: a) True
Explanation:
While method overriding is one of
Java’s most powerful features, there
will be times when you will want to
prevent it from occurring. To disallow
a method from being overridden,
specify final as a modifier at the start
of its declaration.
Methods declared as final cannot be
overridden. If you attempt to do so, a
compile-time error will result.
Page: 25
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 13
How would you will prevent a class
from being inherited?
a) By making the class abstract
b) By adding a comment statement
"Don't Inherit"
c) Precede the class declaration
with final
d) Requesting others to not inherit
the class
Page: 26
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 13 (Solution)
Ans: c) Precede the class
declaration with final
Explanation: Sometimes you will want
to prevent a class from being inherited. To
do this, precede the class declaration with
final.Declaring a class as final implicitly
declares all of its methods as final, too.
Here is an example of a final class:
final class A {
// ...
}
// The following class is illegal.
class B extends A { // ERROR! Can't
subclass A
// ...
}
Page: 27
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 14
It is illegal to declare a class as
both abstract and final. Yes or No?
a) Yes, it is illegal
b) No, it is completely legal.
Page: 28
MCQs Bank on Object Oriented Programming
Topic : Abstract Classes
MCQ No: 14 (Solution)
Ans: a) Yes, it is illegal
Explanation:
It is illegal to declare a class as both
abstract and final since an abstract
class is incomplete by itself and
relies upon its subclasses to provide
complete implementations.
Page: 29
Ad

More Related Content

What's hot (20)

L14 exception handling
L14 exception handlingL14 exception handling
L14 exception handling
teach4uin
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
Dhruvin Nakrani
 
OOPS In JAVA.pptx
OOPS In JAVA.pptxOOPS In JAVA.pptx
OOPS In JAVA.pptx
Sachin33417
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
Hamid Ghorbani
 
Java Notes
Java NotesJava Notes
Java Notes
Abhishek Khune
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
harsh kothari
 
Java - Exception Handling Concepts
Java - Exception Handling ConceptsJava - Exception Handling Concepts
Java - Exception Handling Concepts
Victer Paul
 
Java Beans
Java BeansJava Beans
Java Beans
Ankit Desai
 
Java awt
Java awtJava awt
Java awt
Arati Gadgil
 
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
Elizabeth Thomas
 
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Kuntal Bhowmick
 
Graphical User Interface in JAVA
Graphical User Interface in JAVAGraphical User Interface in JAVA
Graphical User Interface in JAVA
suraj pandey
 
Entity beans in java
Entity beans in javaEntity beans in java
Entity beans in java
Acp Jamod
 
Composite pattern
Composite patternComposite pattern
Composite pattern
Shakil Ahmed
 
Java Multiple Choice Questions and Answers
Java Multiple Choice Questions and AnswersJava Multiple Choice Questions and Answers
Java Multiple Choice Questions and Answers
Java Projects
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
jaimefrozr
 
L14 exception handling
L14 exception handlingL14 exception handling
L14 exception handling
teach4uin
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
Dhruvin Nakrani
 
OOPS In JAVA.pptx
OOPS In JAVA.pptxOOPS In JAVA.pptx
OOPS In JAVA.pptx
Sachin33417
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Java - Exception Handling Concepts
Java - Exception Handling ConceptsJava - Exception Handling Concepts
Java - Exception Handling Concepts
Victer Paul
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
Elizabeth Thomas
 
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Kuntal Bhowmick
 
Graphical User Interface in JAVA
Graphical User Interface in JAVAGraphical User Interface in JAVA
Graphical User Interface in JAVA
suraj pandey
 
Entity beans in java
Entity beans in javaEntity beans in java
Entity beans in java
Acp Jamod
 
Java Multiple Choice Questions and Answers
Java Multiple Choice Questions and AnswersJava Multiple Choice Questions and Answers
Java Multiple Choice Questions and Answers
Java Projects
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
jaimefrozr
 

Similar to Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abstract classes (20)

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 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
 
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
 
Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)
smumbahelp
 
Devry CIS 247 Full Course Latest
Devry CIS 247 Full Course LatestDevry CIS 247 Full Course Latest
Devry CIS 247 Full Course Latest
Atifkhilji
 
Java How to Program 9th Edition Deitel Test Bank
Java How to Program 9th Edition Deitel Test BankJava How to Program 9th Edition Deitel Test Bank
Java How to Program 9th Edition Deitel Test Bank
vorfiatraba
 
Java scjp-part1
Java scjp-part1Java scjp-part1
Java scjp-part1
Raghavendra V Gayakwad
 
Ganesh groups
Ganesh groupsGanesh groups
Ganesh groups
Ganesh Amirineni
 
Advanced programming topics asma
Advanced programming topics asmaAdvanced programming topics asma
Advanced programming topics asma
AbdullahJana
 
Session 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and InterfacesSession 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and Interfaces
PawanMM
 
Big Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test BankBig Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test Bank
cavilecsillu
 
Bt0074, oops with java
Bt0074, oops with javaBt0074, oops with java
Bt0074, oops with java
smumbahelp
 
CIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.comCIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.com
KeatonJennings91
 
Big Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test BankBig Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test Bank
boyziefillho
 
JavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
JavaScript The Web Warrior Series 6th Edition Vodnik Test BankJavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
JavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
sabogaraony
 
Big Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test BankBig Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test Bank
olematanjesa
 
E4
E4E4
E4
lksoo
 
JavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
JavaScript The Web Warrior Series 6th Edition Vodnik Test BankJavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
JavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
poinaspole
 
Diving in OOP (Day 3): Polymorphism and Inheritance (Dynamic Binding/Run Time...
Diving in OOP (Day 3): Polymorphism and Inheritance (Dynamic Binding/Run Time...Diving in OOP (Day 3): Polymorphism and Inheritance (Dynamic Binding/Run Time...
Diving in OOP (Day 3): Polymorphism and Inheritance (Dynamic Binding/Run Time...
Akhil Mittal
 
OOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesOOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and Interfaces
Hitesh-Java
 
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 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
 
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
 
Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)
smumbahelp
 
Devry CIS 247 Full Course Latest
Devry CIS 247 Full Course LatestDevry CIS 247 Full Course Latest
Devry CIS 247 Full Course Latest
Atifkhilji
 
Java How to Program 9th Edition Deitel Test Bank
Java How to Program 9th Edition Deitel Test BankJava How to Program 9th Edition Deitel Test Bank
Java How to Program 9th Edition Deitel Test Bank
vorfiatraba
 
Advanced programming topics asma
Advanced programming topics asmaAdvanced programming topics asma
Advanced programming topics asma
AbdullahJana
 
Session 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and InterfacesSession 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and Interfaces
PawanMM
 
Big Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test BankBig Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test Bank
cavilecsillu
 
Bt0074, oops with java
Bt0074, oops with javaBt0074, oops with java
Bt0074, oops with java
smumbahelp
 
CIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.comCIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.com
KeatonJennings91
 
Big Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test BankBig Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test Bank
boyziefillho
 
JavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
JavaScript The Web Warrior Series 6th Edition Vodnik Test BankJavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
JavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
sabogaraony
 
Big Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test BankBig Java Early Objects 5th Edition Horstmann Test Bank
Big Java Early Objects 5th Edition Horstmann Test Bank
olematanjesa
 
JavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
JavaScript The Web Warrior Series 6th Edition Vodnik Test BankJavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
JavaScript The Web Warrior Series 6th Edition Vodnik Test Bank
poinaspole
 
Diving in OOP (Day 3): Polymorphism and Inheritance (Dynamic Binding/Run Time...
Diving in OOP (Day 3): Polymorphism and Inheritance (Dynamic Binding/Run Time...Diving in OOP (Day 3): Polymorphism and Inheritance (Dynamic Binding/Run Time...
Diving in OOP (Day 3): Polymorphism and Inheritance (Dynamic Binding/Run Time...
Akhil Mittal
 
OOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesOOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and Interfaces
Hitesh-Java
 
Ad

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
Kuntal 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-commerce
Kuntal Bhowmick
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
Kuntal Bhowmick
 
DBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental conceptsDBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental concepts
Kuntal Bhowmick
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
Kuntal Bhowmick
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
Kuntal Bhowmick
 
Operating system Interview Questions
Operating system Interview QuestionsOperating system Interview Questions
Operating system Interview Questions
Kuntal Bhowmick
 
Computer Network Interview Questions
Computer Network Interview QuestionsComputer Network Interview Questions
Computer Network Interview Questions
Kuntal Bhowmick
 
C interview questions
C interview  questionsC interview  questions
C interview questions
Kuntal Bhowmick
 
C question
C questionC question
C question
Kuntal 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 test
Kuntal Bhowmick
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
Kuntal Bhowmick
 
CS291(C Programming) assignment
CS291(C Programming) assignmentCS291(C Programming) assignment
CS291(C Programming) assignment
Kuntal Bhowmick
 
C programming guide new
C programming guide newC programming guide new
C programming guide new
Kuntal Bhowmick
 
C lecture notes new
C lecture notes newC lecture notes new
C lecture notes new
Kuntal Bhowmick
 
Shell script assignment 3
Shell script assignment 3Shell script assignment 3
Shell script assignment 3
Kuntal Bhowmick
 
Basic shell programs assignment 1
Basic shell programs assignment 1Basic shell programs assignment 1
Basic shell programs assignment 1
Kuntal 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_manual
Kuntal Bhowmick
 
Shell programming assignment 2
Shell programming assignment 2Shell programming assignment 2
Shell programming assignment 2
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 -- loops
Kuntal 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-commerce
Kuntal Bhowmick
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
Kuntal Bhowmick
 
DBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental conceptsDBMS and Rdbms fundamental concepts
DBMS and Rdbms fundamental concepts
Kuntal Bhowmick
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
Kuntal Bhowmick
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
Kuntal Bhowmick
 
Operating system Interview Questions
Operating system Interview QuestionsOperating system Interview Questions
Operating system Interview Questions
Kuntal Bhowmick
 
Computer Network Interview Questions
Computer Network Interview QuestionsComputer Network Interview Questions
Computer Network Interview Questions
Kuntal 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 test
Kuntal Bhowmick
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
Kuntal Bhowmick
 
CS291(C Programming) assignment
CS291(C Programming) assignmentCS291(C Programming) assignment
CS291(C Programming) assignment
Kuntal Bhowmick
 
Shell script assignment 3
Shell script assignment 3Shell script assignment 3
Shell script assignment 3
Kuntal Bhowmick
 
Basic shell programs assignment 1
Basic shell programs assignment 1Basic shell programs assignment 1
Basic shell programs assignment 1
Kuntal 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_manual
Kuntal Bhowmick
 
Shell programming assignment 2
Shell programming assignment 2Shell programming assignment 2
Shell programming assignment 2
Kuntal Bhowmick
 
Ad

Recently uploaded (20)

Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
Dynamics of Structures with Uncertain Properties.pptx
Dynamics of Structures with Uncertain Properties.pptxDynamics of Structures with Uncertain Properties.pptx
Dynamics of Structures with Uncertain Properties.pptx
University of Glasgow
 
Working with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to ImplementationWorking with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to Implementation
Alabama Transportation Assistance Program
 
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Journal of Soft Computing in Civil Engineering
 
Efficient Algorithms for Isogeny Computation on Hyperelliptic Curves: Their A...
Efficient Algorithms for Isogeny Computation on Hyperelliptic Curves: Their A...Efficient Algorithms for Isogeny Computation on Hyperelliptic Curves: Their A...
Efficient Algorithms for Isogeny Computation on Hyperelliptic Curves: Their A...
IJCNCJournal
 
Redirects Unraveled: From Lost Links to Rickrolls
Redirects Unraveled: From Lost Links to RickrollsRedirects Unraveled: From Lost Links to Rickrolls
Redirects Unraveled: From Lost Links to Rickrolls
Kritika Garg
 
COMPUTER GRAPHICS AND VISUALIZATION :MODULE-1 notes [BCG402-CG&V].pdf
COMPUTER GRAPHICS AND VISUALIZATION :MODULE-1 notes [BCG402-CG&V].pdfCOMPUTER GRAPHICS AND VISUALIZATION :MODULE-1 notes [BCG402-CG&V].pdf
COMPUTER GRAPHICS AND VISUALIZATION :MODULE-1 notes [BCG402-CG&V].pdf
Alvas Institute of Engineering and technology, Moodabidri
 
MODULE 03 - CLOUD COMPUTING- [BIS 613D] 2022 scheme.pptx
MODULE 03 - CLOUD COMPUTING-  [BIS 613D] 2022 scheme.pptxMODULE 03 - CLOUD COMPUTING-  [BIS 613D] 2022 scheme.pptx
MODULE 03 - CLOUD COMPUTING- [BIS 613D] 2022 scheme.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
COMPUTER GRAPHICS AND VISUALIZATION :MODULE-02 notes [BCG402-CG&V].pdf
COMPUTER GRAPHICS AND VISUALIZATION :MODULE-02 notes [BCG402-CG&V].pdfCOMPUTER GRAPHICS AND VISUALIZATION :MODULE-02 notes [BCG402-CG&V].pdf
COMPUTER GRAPHICS AND VISUALIZATION :MODULE-02 notes [BCG402-CG&V].pdf
Alvas Institute of Engineering and technology, Moodabidri
 
Novel Plug Flow Reactor with Recycle For Growth Control
Novel Plug Flow Reactor with Recycle For Growth ControlNovel Plug Flow Reactor with Recycle For Growth Control
Novel Plug Flow Reactor with Recycle For Growth Control
Chris Harding
 
ZJIT: Building a Next Generation Ruby JIT
ZJIT: Building a Next Generation Ruby JITZJIT: Building a Next Generation Ruby JIT
ZJIT: Building a Next Generation Ruby JIT
maximechevalierboisv1
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Computer Security Fundamentals Chapter 1
Computer Security Fundamentals Chapter 1Computer Security Fundamentals Chapter 1
Computer Security Fundamentals Chapter 1
remoteaimms
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
A Survey of Personalized Large Language Models.pptx
A Survey of Personalized Large Language Models.pptxA Survey of Personalized Large Language Models.pptx
A Survey of Personalized Large Language Models.pptx
rutujabhaskarraopati
 
Interfacing PMW3901 Optical Flow Sensor with ESP32
Interfacing PMW3901 Optical Flow Sensor with ESP32Interfacing PMW3901 Optical Flow Sensor with ESP32
Interfacing PMW3901 Optical Flow Sensor with ESP32
CircuitDigest
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning ModelsMode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Journal of Soft Computing in Civil Engineering
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
Dynamics of Structures with Uncertain Properties.pptx
Dynamics of Structures with Uncertain Properties.pptxDynamics of Structures with Uncertain Properties.pptx
Dynamics of Structures with Uncertain Properties.pptx
University of Glasgow
 
Efficient Algorithms for Isogeny Computation on Hyperelliptic Curves: Their A...
Efficient Algorithms for Isogeny Computation on Hyperelliptic Curves: Their A...Efficient Algorithms for Isogeny Computation on Hyperelliptic Curves: Their A...
Efficient Algorithms for Isogeny Computation on Hyperelliptic Curves: Their A...
IJCNCJournal
 
Redirects Unraveled: From Lost Links to Rickrolls
Redirects Unraveled: From Lost Links to RickrollsRedirects Unraveled: From Lost Links to Rickrolls
Redirects Unraveled: From Lost Links to Rickrolls
Kritika Garg
 
Novel Plug Flow Reactor with Recycle For Growth Control
Novel Plug Flow Reactor with Recycle For Growth ControlNovel Plug Flow Reactor with Recycle For Growth Control
Novel Plug Flow Reactor with Recycle For Growth Control
Chris Harding
 
ZJIT: Building a Next Generation Ruby JIT
ZJIT: Building a Next Generation Ruby JITZJIT: Building a Next Generation Ruby JIT
ZJIT: Building a Next Generation Ruby JIT
maximechevalierboisv1
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Computer Security Fundamentals Chapter 1
Computer Security Fundamentals Chapter 1Computer Security Fundamentals Chapter 1
Computer Security Fundamentals Chapter 1
remoteaimms
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
A Survey of Personalized Large Language Models.pptx
A Survey of Personalized Large Language Models.pptxA Survey of Personalized Large Language Models.pptx
A Survey of Personalized Large Language Models.pptx
rutujabhaskarraopati
 
Interfacing PMW3901 Optical Flow Sensor with ESP32
Interfacing PMW3901 Optical Flow Sensor with ESP32Interfacing PMW3901 Optical Flow Sensor with ESP32
Interfacing PMW3901 Optical Flow Sensor with ESP32
CircuitDigest
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 

Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abstract classes

  • 1. MCQs BANK Page: 1 Object Oriented Programming Topic: Abstract Classes 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.: 7
  • 2. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 1 When the keyword _______ appears in a class definition, it means that zero or more of it’s methods are abstract. a) abstract b) default c) static d) public Page: 2
  • 3. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 1 (Solution) Ans: a) abstract Explanation: When the keyword abstract appears in a class definition, it means that zero or more of it’s methods are abstract. Abstract class is a restricted class that cannot be used to create objects (to access it, it must be inherited from another class). Abstract method can only be used in an abstract class, and it does not have a body. The body is provided by the subclass (inherited from). Page: 3
  • 4. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 2 An _________ method has no body. Fill in the blank. a) static b) abstract c) private d) public Page: 4
  • 5. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 2 (Solution) Ans: b) abstract Explanation: An abstract method has no body. Some of the subclass has to override it and provide the implementation. Abstract methods are declaration only and it will not have implementation. It will not have a method body. A Java class containing an abstract class must be declared as abstract class. Page: 5
  • 6. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 3 Objects cannot be created out of abstract class. True or False a) True b) False Page: 6
  • 7. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 3 (Solution) Ans: a) True Explanation: Objects cannot be created out of abstract class. Abstract classes basically provide a guideline for the properties and methods of an object. Page: 7
  • 8. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 4 An abstract class, which declared with the “abstract” keyword, cannot be instantiated. True or False? a) True b) False Page: 8
  • 9. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 4 (Solution) Ans: a) True Explanation: An abstract class, which declared with the “abstract” keyword, cannot be instantiated. This is because in abstract class the methods are declared only without defining them. Abstract classes cannot be instantiated, but they can be sub classed. Page: 9
  • 10. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 5 In order to use abstract classes, they have to be ______________ . Fill in the blank. a) subclassed b) sub-divided c) overridden d) overloaded Page: 10
  • 11. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 5 (Solution) Ans: a) subclassed Explanation: In order to use abstract classes, they have to be subclassed. There are situations in which you want to define a superclass that declares the structure of a given abstraction without providing a complete implementation of every method. That is, sometimes you want to create a superclass that only defines generalized form that will be shared by all of its subclasses, leaving it to each subclass to fill in the details. Page: 11
  • 12. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 6 ___________ are those methods that must be overridden by subclasses because they have no implementation specified in the superclass. Fill in the blank. a) default methods b) abstract methods c) static methods d) hidden methods Page: 12
  • 13. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 6 (Solution) Ans: b) abstract methods Explanation: Consider a class Triangle. It has no meaning if area( ) is not defined. In this case, you want some way to ensure that a subclass does, indeed, override all necessary methods. Java’s solution to this problem is the abstract method. You can require that certain methods be overridden by subclasses by specifying the abstract type modifier. These methods are sometimes referred to as subclasser responsibility because they have no implementation specified in the superclass. Thus, a subclass must override them—it cannot simply use the version defined in the superclass. Page: 13
  • 14. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 7 The correct way of declaring an abstract method is a) abstract return_type method_name(parameter-list); b) return_type method_name(parameter-list) abstract ; c) return_type abstract method_name(parameter-list); d) all are correct Page: 14
  • 15. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 7 (Solution) Ans: a) abstract return_type method_name(parameter-list); Explanation: The correct way of declaring an abstract method is : abstract return_type method_name(parameter-list); As you can see, no method body is present. Any class that contains one or more abstract methods must also be declared abstract. Page: 15
  • 16. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 8 There can be no objects of an abstract class. True or False a) True b) False Page: 16
  • 17. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 8 (Solution) Ans: a) True Explanation: There can be no objects of an abstract class. That is, an abstract class cannot be directly instantiated with the new operator. Such objects would be useless, because an abstract class is not fully defined. Page: 17
  • 18. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 9 Can you declare abstract constructors, or abstract static methods ? a) Yes b) No Page: 18
  • 19. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 9 (Solution) Ans: b) No Explanation: You cannot declare abstract constructors, or abstract static methods. Constructors are invoked automatically when objects of a class is created using new operator. As an abstract class cannot be directly instantiated with the new operator so you cannot declare abstract constructors. static methods are class methods, that is shared by multiple objects(instances of the class) of a class, as an abstract class cannot be directly instantiated so it is not possible to declare abstract static methods. Page: 19
  • 20. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 10 Any subclass of an abstract class must either implement all of the abstract methods in the superclass, or be itself declared abstract. True or False? a) True b) False Page: 20
  • 21. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 10 (Solution) Ans: a) True Explanation: Any subclass of an abstract class must either implement all of the abstract methods in the superclass, or be itself declared abstract. Page: 21
  • 22. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 11 Is it possible to create a reference to an abstract class so that it can be used to point to a subclass object ? a) Yes, Possible b) No, Not Possible Page: 22
  • 23. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 11 (Solution) Ans: a) Yes, Possible Explanation: Although abstract classes cannot be used to instantiate objects, they can be used to create object references, because Java’s approach to run-time polymorphism is implemented through the use of superclass references. Thus, it must be possible to create a reference to an abstract class so that it can be used to point to a subclass object. It is through superclass reference variables that overridden methods are resolved at run time. Page: 23
  • 24. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 12 Methods declared as final cannot be overridden. True or False a) True b) False Page: 24
  • 25. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 12 (Solution) Ans: a) True Explanation: While method overriding is one of Java’s most powerful features, there will be times when you will want to prevent it from occurring. To disallow a method from being overridden, specify final as a modifier at the start of its declaration. Methods declared as final cannot be overridden. If you attempt to do so, a compile-time error will result. Page: 25
  • 26. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 13 How would you will prevent a class from being inherited? a) By making the class abstract b) By adding a comment statement "Don't Inherit" c) Precede the class declaration with final d) Requesting others to not inherit the class Page: 26
  • 27. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 13 (Solution) Ans: c) Precede the class declaration with final Explanation: Sometimes you will want to prevent a class from being inherited. To do this, precede the class declaration with final.Declaring a class as final implicitly declares all of its methods as final, too. Here is an example of a final class: final class A { // ... } // The following class is illegal. class B extends A { // ERROR! Can't subclass A // ... } Page: 27
  • 28. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 14 It is illegal to declare a class as both abstract and final. Yes or No? a) Yes, it is illegal b) No, it is completely legal. Page: 28
  • 29. MCQs Bank on Object Oriented Programming Topic : Abstract Classes MCQ No: 14 (Solution) Ans: a) Yes, it is illegal Explanation: It is illegal to declare a class as both abstract and final since an abstract class is incomplete by itself and relies upon its subclasses to provide complete implementations. Page: 29
  翻译: