SlideShare a Scribd company logo
1 of 41
Download to read offline
MCQs BANK
Page: 1
Object Oriented
Programming
Topic: Class,Objects,
Conditional Statements
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.: 3
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 1
A _______ is the blueprint from
which individual objects are
created. Fill in the blank.
a) class
b) object
c) instance
d) structure
Page: 2
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 1 (Solution)
Ans: a) class
Explanation:
A class is the blueprint from which
individual objects are created. In
object-oriented terms, we say that
the object you create is an
instance of the class of objects.
Page: 3
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 2
Fill in the following blanks:-
Member variables in a class—these are
called _________ .
Variables in a method or block of
code—these are called ___________ .
Variables in method declarations—
these are called __________.
a) parameters, fields, local variables
b) fields, local variables, parameters
c) local variables, parameters, fields
d) parameters, local variables, fields
Page: 4
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 2 (Solution)
Ans: b) fields, local variables,
parameters
Explanation:
Member variables in a class—
these are called fields.
Variables in a method or block of
code—these are called local
variables.
Variables in method declarations—
these are called parameters.
Page: 5
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 3
The ________ keyword is a Java
operator that creates the object. Fill
in the blank.
a) const
b) new
c) static
d) import
Page: 6
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 3 (Solution)
Ans: b) new
Explanation: The new keyword is a
Java operator that creates the
object. The new operator is followed
by a call to a constructor, which
initializes the new object. Example:
Bicycle bike1 = new Bicycle(); it
creates an object of the Bicycle
class.
The new operator instantiates a
class by allocating memory for a
new object and returning a
reference to that memory. The
new operator also invokes the
object constructor.
Page: 7
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 4
The phrase "instantiating a class"
means the same thing as
______________ . Fill in the blank.
a) "creating an class."
b) "declaring a reference."
c) "creating an object."
d) "rename an object."
Page: 8
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 4 (Solution)
Ans: c) "creating an object."
Explanation:
The phrase "instantiating a class"
means the same thing as "creating
an object." When you create an
object, you are creating an
"instance" of a class, therefore
"instantiating" a class.
If you declare a reference like this:
class ref; the value of "ref" will be
undetermined until an object is
actually created and assigned to it.
Simply declaring a reference variable
does not create an object.
Page: 9
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 5
A _________ can be recognized
easily, because its declaration
uses the same name as the class
and it has no return type. Fill in the
blank.
a) method
b) constructor
c) destructor
d) reference
Page: 10
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 5 (Solution)
Ans: b) constructor
Explanation: Consider the following
class:-
This class contains a single
constructor. You can recognize a
constructor because its declaration
uses the same name as the class
and it has no return type.
Page: 11
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 6
If a class has multiple constructors,
they must have different
signatures. True or False
a) True
b) False
Page: 12
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 6 (Solution)
Ans: a) True
Explanation:
If a class has multiple constructors,
they must have different signatures.
The Java compiler differentiates the
constructors based on the number
and the type of the arguments.
Page: 13
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 7
All classes have at least one
constructor. If a class does not
explicitly declare any, the Java
compiler automatically provides
a no-argument constructor, called
the default constructor. True or
False
a) True
b) False
Page: 14
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 7 (Solution)
Ans: a) True
Explanation:
All classes have at least one
constructor. If a class does not
explicitly declare any, the Java
compiler automatically provides
a no-argument constructor, called
the default constructor. This default
constructor calls the class parent's
no-argument constructor, or the
Object constructor if the class has
no other parent. If the parent has no
constructor (Object does have
one), the compiler will reject the
program.
Page: 15
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 8
The data type of the value returned
by the method,( or void if the
method does not return a value) is
called ________. Fill in the blank.
a) return type
b) method name
c) parameters list
d) method signature
Page: 16
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 8 (Solution)
Ans: a) return type
Explanation: The return type—the data
type of the value returned by the method,
or void if the method does not return a
value.
The parameter list in parenthesis—a
comma-delimited list of input parameters,
preceded by their data types, enclosed by
parentheses, (). If there are no
parameters, you must use empty
parentheses.
Two of the components of a method
declaration comprise the method
signature—the method's name and the
parameter types. Example:
calculateAnswer(double, int, double,
double)
Page: 17
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 9
Typically, a method has a unique
name within its class. However, a
method might have the same name
as other methods due to
_________ . Fill in the blank.
a) method overriding
b) method overloading
c) both (a) and (b)
d) lack of new method name
Page: 18
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 9 (Solution)
Ans: c) both (a) and (b)
Explanation: Typically, a method
has a unique name within its class.
However, a method might have the
same name as other methods
due to method overloading.
If a subclass provides the specific
implementation of the method that
has been declared by one of its
parent class, it is known as method
overriding.
Page: 19
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 10
The Java programming language
supports overloading methods, and
Java can distinguish between
methods with different
_____________ . Fill in the blank.
a) method return type
b) method names
c) method signatures
d) method body
Page: 20
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 10 (Solution)
Ans: c) method signatures
Explanation: The Java language
supports overloading methods, and Java
can distinguish between methods with
different method signatures. This means
that methods within a class can have the
same name if they have different
parameter lists. Overloaded methods are
differentiated by the number and the type
of the arguments passed into the method.
You cannot declare more than one method
with the same name and the same number
and type of arguments, because the
compiler cannot tell them apart. The
compiler does not consider return type
when differentiating methods, so you
cannot declare two methods with the same
signature even if they have a different
return type.
Page: 21
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 11
A _________ is a special method
that is used to initialize a newly
created object and is called just
after the memory is allocated for
the object. It can be used to
initialize the objects ,to required ,or
default values at the time of object
creation.
a) destructor
b) new
c) constructor
d) static
Page: 22
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 11 (Solution)
Ans: c) constructor
Explanation:
A constructor is a special method
that is used to initialize a newly
created object and is called just after
the memory is allocated for the
object. It can be used to initialize the
objects ,to required ,or default values
at the time of object creation. It is not
mandatory for the coder to write a
constructor for the class. If no user
defined constructor is provided for a
class, compiler initializes member
variables to its default values.
Page: 23
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 12
In order to create a Constructor
observe the following rules
1. It has the same name as the
class
2. It should not return a value not
even void
a) Both rules are TRUE
b) Only the rule 1 is TRUE
c) Only the rule 2 is TRUE
d) Both rules are FALSE
Page: 24
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 12 (Solution)
Ans: a) Both rules are TRUE
Explanation:
In order to create a Constructor
observe the following rules
1. It has the same name as the class
2. It should not return a value not
even void
If no user defined constructor is
provided for a class, compiler
initializes member variables to its
default values.
Page: 25
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 13
Constructor overloading is a
technique in Java in which a class
can have any number of
constructors that differ in
_____________. Fill in the blank.
a) return type
b) parameter lists
c) constructor body
d) constructor name
Page: 26
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 13 (Solution)
Ans: b) parameter lists
Explanation:
Constructor overloading is a
technique in Java in which a class
can have any number of constructors
that differ in parameter lists. The
compiler differentiates these
constructors by taking into account
the number of parameters in the list
and their type.
Examples of valid constructors for
class Account are
Account(int a);
Account (int a,int b);
Account (String a,int b);
Page: 27
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 14
Java allows you to control access
to classes, methods, and fields via
so-called __________. Fill in the
blank.
a) encapsulation
b) constructors
c) access specifiers
d) polymorphism
Page: 28
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 14 (Solution)
Ans: c) access specifiers
Explanation:
One of the techniques in object-oriented
programming is encapsulation. It
concerns the hiding of data in a class and
making this class available only through
methods. In this way the chance of
making accidental mistakes in changing
values is minimized. Java allows you to
control access to classes, methods, and
fields via so-called access specifiers.
Java offers four access specifiers, listed
below in decreasing accessibility:
• public
• protected
• default (no specifier)
• private
Page: 29
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 15
__________ classes, methods,
and fields can be accessed from
everywhere. Fill in the blank.
a) private
b) public
c) protected
d) default
Page: 30
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 15 (Solution)
Ans: b) public
Explanation: public classes, methods,
and fields can be accessed from
everywhere. The only constraint is that a
file with Java source code can only
contain one public class whose name
must also match with the filename. You
use public classes, methods, or fields only
if you explicitly want to offer access to
these entities and if this access cannot do
any harm.
If you do not set access to specific level,
then such a class, method, or field will be
accessible from inside the same package
to which the class, method, or field
belongs, but not from outside this
package.
Page: 31
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 16
___________ access level when it
is appropriate for a class's
subclasses to have access to the
method or field, but not for
unrelated classes. Fill in the blank.
a) default
b) protected
c) public
d) private
Page: 32
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 16 (Solution)
Ans: b) protected
Explanation:
protected methods and fields can
only be accessed within the same
class to which the methods and
fields belong, within its subclasses,
and within classes of the same
package, but not from anywhere
else. You use the protected access
level when it is appropriate for a
class's subclasses to have access to
the method or field, but not for
unrelated classes.
Page: 33
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 17
________ methods and fields can
only be accessed within the same
class to which the methods and
fields belong. Fill in the blank.
a) private
b) public
c) protected
d) default
Page: 34
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 17 (Solution)
Ans: a) private
Explanation:
private methods and fields can only
be accessed within the same class to
which the methods and fields belong.
private methods and fields are not
visible within subclasses and are not
inherited by subclasses. So, the
private access specifier is opposite to
the public access specifier. It is mostly
used for encapsulation: data are
hidden within the class and accessor
methods are provided.
Page: 35
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 18
The conditional expression of an if-
statement in java must be a
_______________ . Fill in the
blank.
a) Arithmetic expression
b) Boolean expression
c) Non- Zero value
d) Zero value
Page: 36
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 18 (Solution)
Ans: b) Boolean expression
Explanation:
The if statement executes a block of
code only if the specified expression
is true. If the value is false, then the
if block is skipped and execution
continues with the rest of the
program. Note that the conditional
expression must be a Boolean
expression, which must give TRUE
or FALSE value. Any other
value(Zero or Non-Zero value) will
give compilation error.
Page: 37
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 19
The switch statement code block in
Java includes a __________ label
to use in cases where there are no
matches are found. Fill in the
blank.
a) outer
b) default
c) inner
d) continue
Page: 38
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 19 (Solution)
Ans: b) default
Explanation:
The switch case statement, also
called a case statement is a multi-way
branch with several choices. A switch
is easier to implement than a series of
if/else statements. The default level is
used to execute statements when no
matches are found.
Page: 39
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 20
When executing a switch
statement, the program falls
through to the next case.
Therefore, if you want to exit in the
middle of the switch statement
code block, you must insert a
_______________ . Fill in the
blank.
a) case statement
b) default statement
c) break statement
d) continue statement
Page: 40
MCQs Bank on Object Oriented Programming
Topic: Class,Objects,Conditional Statements
MCQ No: 20 (Solution)
Ans: c) break statement
Explanation:
When executing a switch statement,
the program falls through to the next
case. Therefore, if you want to exit in
the middle of the switch statement
code block, you must insert a break
statement, which causes the
program to continue executing after
the current code block.
Page: 41

More Related Content

What's hot

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
 
Java- Concurrent programming - Synchronization (part 2)
Java- Concurrent programming - Synchronization (part 2)Java- Concurrent programming - Synchronization (part 2)
Java- Concurrent programming - Synchronization (part 2)Riccardo Cardin
 
Building a web application with ontinuation monads
Building a web application with ontinuation monadsBuilding a web application with ontinuation monads
Building a web application with ontinuation monadsSeitaro Yuuki
 
Close Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet codeClose Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet codelbergmans
 
Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati Technologies
Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati TechnologiesClojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati Technologies
Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati TechnologiesPramati Technologies
 
Java session13
Java session13Java session13
Java session13Niit Care
 
A (too) Short Introduction to Scala
A (too) Short Introduction to ScalaA (too) Short Introduction to Scala
A (too) Short Introduction to ScalaRiccardo Cardin
 
Review of c_sharp2_features_part_ii
Review of c_sharp2_features_part_iiReview of c_sharp2_features_part_ii
Review of c_sharp2_features_part_iiNico Ludwig
 
Std 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsStd 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsNuzhat Memon
 
Bicliques for Preimages: Attacks on Skein-512 and the SHA-2 family
Bicliques for Preimages: Attacks on Skein-512 and the SHA-2 familyBicliques for Preimages: Attacks on Skein-512 and the SHA-2 family
Bicliques for Preimages: Attacks on Skein-512 and the SHA-2 familyAlexandra
 
Predicting Defects using Network Analysis on Dependency Graphs
Predicting Defects using Network Analysis on Dependency GraphsPredicting Defects using Network Analysis on Dependency Graphs
Predicting Defects using Network Analysis on Dependency GraphsThomas Zimmermann
 

What's hot (16)

Java mcq
Java mcqJava mcq
Java mcq
 
Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)
 
Java- Concurrent programming - Synchronization (part 2)
Java- Concurrent programming - Synchronization (part 2)Java- Concurrent programming - Synchronization (part 2)
Java- Concurrent programming - Synchronization (part 2)
 
Building a web application with ontinuation monads
Building a web application with ontinuation monadsBuilding a web application with ontinuation monads
Building a web application with ontinuation monads
 
Google lme4
Google lme4Google lme4
Google lme4
 
Close Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet codeClose Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet code
 
Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati Technologies
Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati TechnologiesClojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati Technologies
Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati Technologies
 
Java session13
Java session13Java session13
Java session13
 
A (too) Short Introduction to Scala
A (too) Short Introduction to ScalaA (too) Short Introduction to Scala
A (too) Short Introduction to Scala
 
Review of c_sharp2_features_part_ii
Review of c_sharp2_features_part_iiReview of c_sharp2_features_part_ii
Review of c_sharp2_features_part_ii
 
Std 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsStd 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQs
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
 
Bicliques for Preimages: Attacks on Skein-512 and the SHA-2 family
Bicliques for Preimages: Attacks on Skein-512 and the SHA-2 familyBicliques for Preimages: Attacks on Skein-512 and the SHA-2 family
Bicliques for Preimages: Attacks on Skein-512 and the SHA-2 family
 
Exploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systemsExploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systems
 
Java reflection
Java reflectionJava reflection
Java reflection
 
Predicting Defects using Network Analysis on Dependency Graphs
Predicting Defects using Network Analysis on Dependency GraphsPredicting Defects using Network Analysis on Dependency Graphs
Predicting Defects using Network Analysis on Dependency Graphs
 

Similar to Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- class,objects,conditional statements

Class notes(week 3) on class objects and methods
Class notes(week 3) on class objects and methodsClass notes(week 3) on class objects and methods
Class notes(week 3) on class objects and methodsKuntal Bhowmick
 
Class notes(week 3) on class objects and methods
Class notes(week 3) on class objects and methodsClass notes(week 3) on class objects and methods
Class notes(week 3) on class objects and methodsKuntal Bhowmick
 
While writing program in any language, you need to use various variables to s...
While writing program in any language, you need to use various variables to s...While writing program in any language, you need to use various variables to s...
While writing program in any language, you need to use various variables to s...bhargavi804095
 
Messages, Instances and Initialization
Messages, Instances and InitializationMessages, Instances and Initialization
Messages, Instances and Initializationadil raja
 
Constructors and destructors in C++
Constructors and destructors in  C++Constructors and destructors in  C++
Constructors and destructors in C++RAJ KUMAR
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Sopheak Sem
 
Devry CIS 247 Full Course Latest
Devry CIS 247 Full Course LatestDevry CIS 247 Full Course Latest
Devry CIS 247 Full Course LatestAtifkhilji
 
Bca2030 object oriented programming – c++
Bca2030   object oriented programming – c++Bca2030   object oriented programming – c++
Bca2030 object oriented programming – c++smumbahelp
 
Constructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdfConstructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdfLadallaRajKumar
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in javaagorolabs
 
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_0806 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08Niit Care
 

Similar to Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- class,objects,conditional statements (20)

Class notes(week 3) on class objects and methods
Class notes(week 3) on class objects and methodsClass notes(week 3) on class objects and methods
Class notes(week 3) on class objects and methods
 
Class notes(week 3) on class objects and methods
Class notes(week 3) on class objects and methodsClass notes(week 3) on class objects and methods
Class notes(week 3) on class objects and methods
 
While writing program in any language, you need to use various variables to s...
While writing program in any language, you need to use various variables to s...While writing program in any language, you need to use various variables to s...
While writing program in any language, you need to use various variables to s...
 
11-Classes.ppt
11-Classes.ppt11-Classes.ppt
11-Classes.ppt
 
Ch03
Ch03Ch03
Ch03
 
Ch03
Ch03Ch03
Ch03
 
Messages, Instances and Initialization
Messages, Instances and InitializationMessages, Instances and Initialization
Messages, Instances and Initialization
 
Top Javascript Q's
Top Javascript Q'sTop Javascript Q's
Top Javascript Q's
 
Constructors and destructors in C++
Constructors and destructors in  C++Constructors and destructors in  C++
Constructors and destructors in C++
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02
 
Introduction of C# & MVC
Introduction of C# & MVCIntroduction of C# & MVC
Introduction of C# & MVC
 
Devry CIS 247 Full Course Latest
Devry CIS 247 Full Course LatestDevry CIS 247 Full Course Latest
Devry CIS 247 Full Course Latest
 
Bca2030 object oriented programming – c++
Bca2030   object oriented programming – c++Bca2030   object oriented programming – c++
Bca2030 object oriented programming – c++
 
7494609
74946097494609
7494609
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Constructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdfConstructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdf
 
Javascript Question
Javascript QuestionJavascript Question
Javascript Question
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
 
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_0806 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
 

More from 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-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
 
Solution manual of shell programming assignment 2
Solution manual of shell programming assignment 2Solution manual of shell programming assignment 2
Solution manual of shell programming assignment 2Kuntal Bhowmick
 

More from Kuntal Bhowmick (20)

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
 
Solution manual of shell programming assignment 2
Solution manual of shell programming assignment 2Solution manual of shell programming assignment 2
Solution manual of shell programming assignment 2
 

Recently uploaded

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...Call girls in Ahmedabad High profile
 

Recently uploaded (20)

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
 

Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- class,objects,conditional statements

  • 1. MCQs BANK Page: 1 Object Oriented Programming Topic: Class,Objects, Conditional Statements 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.: 3
  • 2. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 1 A _______ is the blueprint from which individual objects are created. Fill in the blank. a) class b) object c) instance d) structure Page: 2
  • 3. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 1 (Solution) Ans: a) class Explanation: A class is the blueprint from which individual objects are created. In object-oriented terms, we say that the object you create is an instance of the class of objects. Page: 3
  • 4. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 2 Fill in the following blanks:- Member variables in a class—these are called _________ . Variables in a method or block of code—these are called ___________ . Variables in method declarations— these are called __________. a) parameters, fields, local variables b) fields, local variables, parameters c) local variables, parameters, fields d) parameters, local variables, fields Page: 4
  • 5. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 2 (Solution) Ans: b) fields, local variables, parameters Explanation: Member variables in a class— these are called fields. Variables in a method or block of code—these are called local variables. Variables in method declarations— these are called parameters. Page: 5
  • 6. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 3 The ________ keyword is a Java operator that creates the object. Fill in the blank. a) const b) new c) static d) import Page: 6
  • 7. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 3 (Solution) Ans: b) new Explanation: The new keyword is a Java operator that creates the object. The new operator is followed by a call to a constructor, which initializes the new object. Example: Bicycle bike1 = new Bicycle(); it creates an object of the Bicycle class. The new operator instantiates a class by allocating memory for a new object and returning a reference to that memory. The new operator also invokes the object constructor. Page: 7
  • 8. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 4 The phrase "instantiating a class" means the same thing as ______________ . Fill in the blank. a) "creating an class." b) "declaring a reference." c) "creating an object." d) "rename an object." Page: 8
  • 9. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 4 (Solution) Ans: c) "creating an object." Explanation: The phrase "instantiating a class" means the same thing as "creating an object." When you create an object, you are creating an "instance" of a class, therefore "instantiating" a class. If you declare a reference like this: class ref; the value of "ref" will be undetermined until an object is actually created and assigned to it. Simply declaring a reference variable does not create an object. Page: 9
  • 10. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 5 A _________ can be recognized easily, because its declaration uses the same name as the class and it has no return type. Fill in the blank. a) method b) constructor c) destructor d) reference Page: 10
  • 11. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 5 (Solution) Ans: b) constructor Explanation: Consider the following class:- This class contains a single constructor. You can recognize a constructor because its declaration uses the same name as the class and it has no return type. Page: 11
  • 12. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 6 If a class has multiple constructors, they must have different signatures. True or False a) True b) False Page: 12
  • 13. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 6 (Solution) Ans: a) True Explanation: If a class has multiple constructors, they must have different signatures. The Java compiler differentiates the constructors based on the number and the type of the arguments. Page: 13
  • 14. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 7 All classes have at least one constructor. If a class does not explicitly declare any, the Java compiler automatically provides a no-argument constructor, called the default constructor. True or False a) True b) False Page: 14
  • 15. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 7 (Solution) Ans: a) True Explanation: All classes have at least one constructor. If a class does not explicitly declare any, the Java compiler automatically provides a no-argument constructor, called the default constructor. This default constructor calls the class parent's no-argument constructor, or the Object constructor if the class has no other parent. If the parent has no constructor (Object does have one), the compiler will reject the program. Page: 15
  • 16. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 8 The data type of the value returned by the method,( or void if the method does not return a value) is called ________. Fill in the blank. a) return type b) method name c) parameters list d) method signature Page: 16
  • 17. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 8 (Solution) Ans: a) return type Explanation: The return type—the data type of the value returned by the method, or void if the method does not return a value. The parameter list in parenthesis—a comma-delimited list of input parameters, preceded by their data types, enclosed by parentheses, (). If there are no parameters, you must use empty parentheses. Two of the components of a method declaration comprise the method signature—the method's name and the parameter types. Example: calculateAnswer(double, int, double, double) Page: 17
  • 18. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 9 Typically, a method has a unique name within its class. However, a method might have the same name as other methods due to _________ . Fill in the blank. a) method overriding b) method overloading c) both (a) and (b) d) lack of new method name Page: 18
  • 19. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 9 (Solution) Ans: c) both (a) and (b) Explanation: Typically, a method has a unique name within its class. However, a method might have the same name as other methods due to method overloading. If a subclass provides the specific implementation of the method that has been declared by one of its parent class, it is known as method overriding. Page: 19
  • 20. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 10 The Java programming language supports overloading methods, and Java can distinguish between methods with different _____________ . Fill in the blank. a) method return type b) method names c) method signatures d) method body Page: 20
  • 21. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 10 (Solution) Ans: c) method signatures Explanation: The Java language supports overloading methods, and Java can distinguish between methods with different method signatures. This means that methods within a class can have the same name if they have different parameter lists. Overloaded methods are differentiated by the number and the type of the arguments passed into the method. You cannot declare more than one method with the same name and the same number and type of arguments, because the compiler cannot tell them apart. The compiler does not consider return type when differentiating methods, so you cannot declare two methods with the same signature even if they have a different return type. Page: 21
  • 22. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 11 A _________ is a special method that is used to initialize a newly created object and is called just after the memory is allocated for the object. It can be used to initialize the objects ,to required ,or default values at the time of object creation. a) destructor b) new c) constructor d) static Page: 22
  • 23. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 11 (Solution) Ans: c) constructor Explanation: A constructor is a special method that is used to initialize a newly created object and is called just after the memory is allocated for the object. It can be used to initialize the objects ,to required ,or default values at the time of object creation. It is not mandatory for the coder to write a constructor for the class. If no user defined constructor is provided for a class, compiler initializes member variables to its default values. Page: 23
  • 24. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 12 In order to create a Constructor observe the following rules 1. It has the same name as the class 2. It should not return a value not even void a) Both rules are TRUE b) Only the rule 1 is TRUE c) Only the rule 2 is TRUE d) Both rules are FALSE Page: 24
  • 25. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 12 (Solution) Ans: a) Both rules are TRUE Explanation: In order to create a Constructor observe the following rules 1. It has the same name as the class 2. It should not return a value not even void If no user defined constructor is provided for a class, compiler initializes member variables to its default values. Page: 25
  • 26. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 13 Constructor overloading is a technique in Java in which a class can have any number of constructors that differ in _____________. Fill in the blank. a) return type b) parameter lists c) constructor body d) constructor name Page: 26
  • 27. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 13 (Solution) Ans: b) parameter lists Explanation: Constructor overloading is a technique in Java in which a class can have any number of constructors that differ in parameter lists. The compiler differentiates these constructors by taking into account the number of parameters in the list and their type. Examples of valid constructors for class Account are Account(int a); Account (int a,int b); Account (String a,int b); Page: 27
  • 28. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 14 Java allows you to control access to classes, methods, and fields via so-called __________. Fill in the blank. a) encapsulation b) constructors c) access specifiers d) polymorphism Page: 28
  • 29. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 14 (Solution) Ans: c) access specifiers Explanation: One of the techniques in object-oriented programming is encapsulation. It concerns the hiding of data in a class and making this class available only through methods. In this way the chance of making accidental mistakes in changing values is minimized. Java allows you to control access to classes, methods, and fields via so-called access specifiers. Java offers four access specifiers, listed below in decreasing accessibility: • public • protected • default (no specifier) • private Page: 29
  • 30. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 15 __________ classes, methods, and fields can be accessed from everywhere. Fill in the blank. a) private b) public c) protected d) default Page: 30
  • 31. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 15 (Solution) Ans: b) public Explanation: public classes, methods, and fields can be accessed from everywhere. The only constraint is that a file with Java source code can only contain one public class whose name must also match with the filename. You use public classes, methods, or fields only if you explicitly want to offer access to these entities and if this access cannot do any harm. If you do not set access to specific level, then such a class, method, or field will be accessible from inside the same package to which the class, method, or field belongs, but not from outside this package. Page: 31
  • 32. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 16 ___________ access level when it is appropriate for a class's subclasses to have access to the method or field, but not for unrelated classes. Fill in the blank. a) default b) protected c) public d) private Page: 32
  • 33. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 16 (Solution) Ans: b) protected Explanation: protected methods and fields can only be accessed within the same class to which the methods and fields belong, within its subclasses, and within classes of the same package, but not from anywhere else. You use the protected access level when it is appropriate for a class's subclasses to have access to the method or field, but not for unrelated classes. Page: 33
  • 34. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 17 ________ methods and fields can only be accessed within the same class to which the methods and fields belong. Fill in the blank. a) private b) public c) protected d) default Page: 34
  • 35. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 17 (Solution) Ans: a) private Explanation: private methods and fields can only be accessed within the same class to which the methods and fields belong. private methods and fields are not visible within subclasses and are not inherited by subclasses. So, the private access specifier is opposite to the public access specifier. It is mostly used for encapsulation: data are hidden within the class and accessor methods are provided. Page: 35
  • 36. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 18 The conditional expression of an if- statement in java must be a _______________ . Fill in the blank. a) Arithmetic expression b) Boolean expression c) Non- Zero value d) Zero value Page: 36
  • 37. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 18 (Solution) Ans: b) Boolean expression Explanation: The if statement executes a block of code only if the specified expression is true. If the value is false, then the if block is skipped and execution continues with the rest of the program. Note that the conditional expression must be a Boolean expression, which must give TRUE or FALSE value. Any other value(Zero or Non-Zero value) will give compilation error. Page: 37
  • 38. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 19 The switch statement code block in Java includes a __________ label to use in cases where there are no matches are found. Fill in the blank. a) outer b) default c) inner d) continue Page: 38
  • 39. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 19 (Solution) Ans: b) default Explanation: The switch case statement, also called a case statement is a multi-way branch with several choices. A switch is easier to implement than a series of if/else statements. The default level is used to execute statements when no matches are found. Page: 39
  • 40. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 20 When executing a switch statement, the program falls through to the next case. Therefore, if you want to exit in the middle of the switch statement code block, you must insert a _______________ . Fill in the blank. a) case statement b) default statement c) break statement d) continue statement Page: 40
  • 41. MCQs Bank on Object Oriented Programming Topic: Class,Objects,Conditional Statements MCQ No: 20 (Solution) Ans: c) break statement Explanation: When executing a switch statement, the program falls through to the next case. Therefore, if you want to exit in the middle of the switch statement code block, you must insert a break statement, which causes the program to continue executing after the current code block. Page: 41