SlideShare a Scribd company logo
1 of 29
Download to read offline
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

More Related Content

What's hot

sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using BacktrackingAbhishek Singh
 
Recursion in C++
Recursion in C++Recursion in C++
Recursion in C++Maliha Mehr
 
Java package
Java packageJava package
Java packageCS_GDRCST
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECSreedhar Chowdam
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Kamlesh Makvana
 
itft-Inheritance in java
itft-Inheritance in javaitft-Inheritance in java
itft-Inheritance in javaAtul Sehdev
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentationtigerwarn
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdfchoconyeuquy
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1PRN USM
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++Muhammad Waqas
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance pptNivegeetha
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 

What's hot (20)

sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
Recursion in C++
Recursion in C++Recursion in C++
Recursion in C++
 
Java package
Java packageJava package
Java package
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
 
Method overriding
Method overridingMethod overriding
Method overriding
 
C# Overriding
C# OverridingC# Overriding
C# Overriding
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPREC
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Abstraction
AbstractionAbstraction
Abstraction
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
 
itft-Inheritance in java
itft-Inheritance in javaitft-Inheritance in java
itft-Inheritance in java
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdf
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 

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

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
 
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 LatestAtifkhilji
 
Advanced programming topics asma
Advanced programming topics asmaAdvanced programming topics asma
Advanced programming topics asmaAbdullahJana
 
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 InterfacesPawanMM
 
Bt0074, oops with java
Bt0074, oops with javaBt0074, oops with java
Bt0074, oops with javasmumbahelp
 
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.comKeatonJennings91
 
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
 
Java Multiple Choice Questions and Answers
Java Multiple Choice Questions and AnswersJava Multiple Choice Questions and Answers
Java Multiple Choice Questions and AnswersJava Projects
 
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 InterfacesHitesh-Java
 
Bt8903, c# programming
Bt8903, c# programmingBt8903, c# programming
Bt8903, c# programmingsmumbahelp
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#Muhammad Younis
 
50 common web developer interview questions [2020 updated] [www.full stack....
50 common web developer interview questions [2020 updated]   [www.full stack....50 common web developer interview questions [2020 updated]   [www.full stack....
50 common web developer interview questions [2020 updated] [www.full stack....Alex Ershov
 
25 java tough interview questions
25 java tough interview questions25 java tough interview questions
25 java tough interview questionsArun Banotra
 

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

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...
 
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...
 
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...
 
Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)
 
Devry CIS 247 Full Course Latest
Devry CIS 247 Full Course LatestDevry CIS 247 Full Course Latest
Devry CIS 247 Full Course Latest
 
Java scjp-part1
Java scjp-part1Java scjp-part1
Java scjp-part1
 
Ganesh groups
Ganesh groupsGanesh groups
Ganesh groups
 
Advanced programming topics asma
Advanced programming topics asmaAdvanced programming topics asma
Advanced programming topics asma
 
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
 
Bt0074, oops with java
Bt0074, oops with javaBt0074, oops with java
Bt0074, oops with java
 
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
 
E4
E4E4
E4
 
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...
 
Java Multiple Choice Questions and Answers
Java Multiple Choice Questions and AnswersJava Multiple Choice Questions and Answers
Java Multiple Choice Questions and Answers
 
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
 
Bt8903, c# programming
Bt8903, c# programmingBt8903, c# programming
Bt8903, c# programming
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
 
9 abstract interface
9 abstract interface9 abstract interface
9 abstract interface
 
50 common web developer interview questions [2020 updated] [www.full stack....
50 common web developer interview questions [2020 updated]   [www.full stack....50 common web developer interview questions [2020 updated]   [www.full stack....
50 common web developer interview questions [2020 updated] [www.full stack....
 
25 java tough interview questions
25 java tough interview questions25 java tough interview questions
25 java tough interview questions
 

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

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
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
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptxrouholahahmadi9876
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptAfnanAhmad53
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxMuhammadAsimMuhammad6
 
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
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
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
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
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
 

Recently uploaded (20)

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
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
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .ppt
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.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...
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
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
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
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
 

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