Chapter: Classes and objects in Java β’ Total: 321 MCQs
MCQ 1Constructors
which Is a special kind of method that is invoked when a new object is created ?
Alocal
Binstance
Cconstructors
Dstatic
Correct Answer: Option C
Note: GSEB Commerce Oct-2020
MCQ 2Visibility modifiers for Access Control
Which of the following level of protection is used to allow the access only to subclasses or to share with friend methods?
Aprotected
Bpublic
Cpackage
Dprivate
Correct Answer: Option A
Note: GSEB Commerce Oct-2020
MCQ 3Class variables and class methods
What is the name of variables of class type refferd to as?
Arelated
Bdynamic
Crefernce
Dall of the above
Correct Answer: Option C
Note: GSEB Commerce Oct-2020
MCQ 4Class in Java
How many components are used to made up every class in java ?
A1
B2
C3
D4
Correct Answer: Option B
Note: GSEB Commerce Oct-2020
MCQ 5Accessor and Mutator Methods
What is the meaning of mutator?
ATo allow such a data to be used by others.
Bto allow such a data to be modified by others.
C(B) and (D) both
DIt is all known as βsetterβ
Correct Answer: Option C
Note: GSEB Commerce Oct-2020
MCQ 6Objects
Which of the following steps are required for creating an object from a class?
ADeclaration, Instantiation,Initialization
BDeclaration, Initialization, Instantiation
CInstantiation, Initialization, Declaration
DInitialization, Instantiation, Declaration
Correct Answer: Option A
Note: GSEB Commerce Oct-2020
MCQ 7Inheritance
Person -> Teachaer class
AComposition
BAggregation
CInheritance
DPolymorphism
Correct Answer: Option C
Note: GSEB Commerce Oct-2020
MCQ 8Visibility modifiers for Access Control
Which statement should be added as the first non-comment or non-blank link in source file of java Β ?
APublic
BProtected
CPrivate
DPackage
Correct Answer: Option D
Note: GSEB Commerce Oct-2020
MCQ 9Classification of variables declared in a class
In java, which variables are defined with static keyboard ?
AClass
BInstance
CLocal
DAll of the above
Correct Answer: Option A
Note: GSEB Commerce Oct-2020
MCQ 10Inheritance
INHERITANCE IS GENERALLY REFERRED AS WHICH TYPE OF REALTIONSHIP BETWEEN TWO CLASSES.
APARTIAL
BFULL
CEXCULSIVE
DIS A KIND OF
Correct Answer: Option D
Note: null
MCQ 11Visibility modifiers for Access Control
IF WE WANT TO MAKE VISIBLE TO ALL THE CLASSES OUTSIDE THE CLASS, WHICH TYPE OF ACCESS MODIFIER IS USED.
APROTECTED
BPACKAGE
CPUBLIC
DPRIVATE
Correct Answer: Option C
Note: null
MCQ 12Methods
FROM THE FOLLOWING WHICH OPREATOR IS USED TO ACCESS INSTANCE VARIABLE AND INSTANCE IN JAVA.
A: (COLON)
B; (SEMICON)
C. (DOT)
D, ( COMMA)
Correct Answer: Option C
Note: null
MCQ 13Inheritance
IN OBJECT ORINTED TERMINOLOGY, THE EXISTING CLASS IS KNOWN AS WHAT
ASUPER CLASS
BPARENT CLASS
CSUB CLASS
DBOTH (A) & (B)
Correct Answer: Option D
Note: null
MCQ 14'new' keyword
WHICH STEPS ARE REQUIRED TO CREATE OBJECT FROM A CLASS IN JAVA.
ADECLARATION
BINSTANTITATION
CINITIALIZATION
DALL OF THESE
Correct Answer: Option D
Note: null
MCQ 15Objects
IN OBJECT-ORIENTED PROGRAMMING (OOP) LANGUAGES, CREATING AN OBJECT IS ALSO KNOWN AS WHAT.
AOBJECT INSTANTITAON
BOBJECT CREATION
COBJECT MAKING
DNONE OF THIS
Correct Answer: Option A
Note: null
MCQ 16Visibility modifiers for Access Control
WHICH IS THE DEAFULT LEVEL OF PROTECTION, WHERE LACK OF ANY ACCESS MODIFIER KEYWORD IS IN A JAVA.
APUBLIC
BPACKAGE
CPROTECTED
DPRIVATE
Correct Answer: Option B
Note: null
MCQ 17Accessor and Mutator Methods
IN JAVA IF WE WANT TO ALLOW DATA DIRECTLY ACCESSED BY METHODS OF OTHER CLASS USED.
AGETTER
BSETTER
CMAIN
DVOID
Correct Answer: Option A
Note: null
MCQ 18Visibility modifiers for Access Control
FROM THE FOLLOWING WHICH TYPE OF VISIBILITY MODIFIERS ARE USED TO PROTECT A METHOD OR VARIABLES?
APUBLIC
BPACKAGE
CPROTECETED
DALL OF THESE
Correct Answer: Option D
Note: null
MCQ 19Class in Java
IN JAVA A CLASS IS DEFINED USING WHICH KEYWORD.
ACLASS
BPUBLIC
CSTATIC
DMAIN
Correct Answer: Option A
Note: null
MCQ 20Classification of variables declared in a class
WHICH TYPE OF VARIABLES ARE DEFINED INSIDE METHODS OR BLOCK.
Aclass variable
Bglobal variable
Cstatic variable
Dlocal variable
Correct Answer: Option D
Note: null
MCQ 21Inheritance
In class diagram, which of the following symbol is used to represent inheritance?
AEmpty diamond symbol
BFill diamond symbol
CArrow diamond symbol
DArrow symbol
Correct Answer: Option D
MCQ 22Introduction
Which of the following allows us to build new class with added capabilities by extending existing class ?
AComposition
BInheritance
CAggregation
DPolymorphism
Correct Answer: Option B
Note: null
MCQ 23Introduction
In Object-oriented programming languages, creating an object is also called as what ?
AObject installation
BObject making
CObject creation
DObject instantiation
Correct Answer: Option D
Note: null
MCQ 24Introduction
Which word means βmany formsβ, different forms of methods with same name in Java ?
AInheritance
BPolymorphism
CComposition
DAggregation
Correct Answer: Option B
Note: null
MCQ 25Introduction
Which of the following is a special kind of method that is invoked when a new object is created ?
AClass
BInstance
CConstructor
DObject
Correct Answer: Option C
Note: S-March-2020
MCQ 26Introduction
Which is the default level of protection, where lack of any access modifier keyword is in a declaration in Java ?
APrivate
BPublic
CPackage
DProtected
Correct Answer: Option C
Note: null
MCQ 27Introduction
In Java, which keyword is used to create the object by allocating memory ?
Asuper
Badd
Cnew
Dclass
Correct Answer: Option C
Note: S-March-2020
MCQ 28Introduction
If we want to allow such data to be modified by others, then which method is used ?
AMutor
BAccessor
CMutator
DAccess
Correct Answer: Option C
Note: null
MCQ 29Introduction
In Java, a class is defined using which keyword ?
Aclass
BCLASS
CAll of these
DClass
Correct Answer: Option A
Note: null
MCQ 30Introduction
Which method is invoked automatically with creation of an object ?
AObject
BInstance
CConstructor
DClass
Correct Answer: Option C
Note: null
MCQ 31Introduction
In Java, how many levels of visibility modifiers are available for access control ?
A3
B2
C5
D4
Correct Answer: Option D
Note: null
MCQ 32Introduction
If we want to allow other methods to read only the data value, then which method is used ?
Awriter
Breader
Cgetter
Dsetter
Correct Answer: Option C
Note: null
MCQ 33Introduction
If we want to allow other methods to modify the data value, then which method is used ?
Agetter
Bwrite
Csetter
Dreader
Correct Answer: Option C
Note: null
MCQ 34Introduction
In Java, who looks for unused objects and reclaims the memory ?
AObject collector
BUnused collector
CGarbage collector
DReclaim collector
Correct Answer: Option C
Note: null
MCQ 35Introduction
If we want to allow such data to be used by others, then which method is used ?
AMutor
BMutator
CAccess
DAccessor
Correct Answer: Option D
Note: null
MCQ 36Introduction
Which of the following method can be called without creating an instance of a class ?
AInstance method
BClass method
CConstructor method
DAll of these
Correct Answer: Option B
Note: null
MCQ 37Introduction
In Inheritance models consist of which type of relationship between two classes ?
Ahave - a
Bwas - a
Cis - a
Dhas - a
Correct Answer: Option C
Note: null
MCQ 38Introduction
How to define user define no-argument constructor ?
ARoom ( ) { };
BRoom { } ( );
CRoom < > ( );
DRoom [ ] { };
Correct Answer: Option A
Note: null
MCQ 39Introduction
In Java, Parent class can be referred to as which of the following ?
AParent class, Super class, Base class
BParent class, Extended class, Base class
CSub class, Base class, Super class
DSub class, Derived class, Extended class
Correct Answer: Option A
Note: null
MCQ 40Introduction
In Java, which step is followed to create an object from a class ?
ADeclaration
BAll of these
CInitialization
DInstantiation
Correct Answer: Option B
Note: S-March-2020
MCQ 41Introduction
Which type of variables are defined inside methods or blocks ?
ALocal variables
BInstance variables
CAll of these
DClass variables
Correct Answer: Option D
Note: null
MCQ 42Introduction
In Java, a class is generally made up of which components ?
ABehaviour, Variable
BName, Attributes
CClass, Variable
DAttributes, Behaviour
Correct Answer: Option D
Note: null
MCQ 43Introduction
Which of the following represents the type of variable ?
ALocal variables
BInstance variables
CClass variables
DAll of these
Correct Answer: Option D
Note: null
MCQ 44Introduction
Which of the following prefix is utilize for conventionally naming of Accessor and Mutator method respectively ?
Apost, get
Bget, post
Cget, set
Dset, get
Correct Answer: Option C
Note: null
MCQ 45Introduction
Mutator method is known as what in Java ?
Aget
Bset
Cgetter
Dsetter
Correct Answer: Option D
Note: null
MCQ 46Introduction
Which of the following defines attributes and methods ?
AObject
BInstance
CClass
DVariable
Correct Answer: Option C
Note: null
MCQ 47Introduction
In Java, which keyword is used to declare Class variable ?
Aclass
Bnew
Cvar
Dstatic
Correct Answer: Option D
Note: null
MCQ 48Introduction
Which are the for Pβs used in the four levels of visibility to provide necessary protection ?
AProcess, Private, Protected, Public
BPublic, Package, Protected, Private
CPrivate, Package, Protected, Public
DPublic, Package, Protected, Process
Correct Answer: Option B
Note: null
MCQ 49Introduction
Which of the following keyword is used to declare Class variables and Class methods ?
Astatic
Bvariable
Cclass
Dobject
Correct Answer: Option D
Note: null
MCQ 50Introduction
Which type of variables are defined with in a class, outside any method with the βstaticβ keyword ?
AAll of these
BClass variables
CInstance variables
DLocal variables
Correct Answer: Option B
Note: null
MCQ 51Introduction
Which of the following in Object-oriented programming language provide reusability feature ?
AConstructors
BInheritance
CPolymorphism
DObjection
Correct Answer: Option B
Note: null
MCQ 52Introduction
All instances of class are allocated memory in data structure is called what ?
AZeap
BReap
CHeap
DLeap
Correct Answer: Option C
Note: null
MCQ 53Introduction
If we want to make visible to all the classes outside the class, where method or variable is visible to class, which type of access modifier is used ?
AProtected
BPrivate
CPackage
DPublic
Correct Answer: Option D
Note: null
MCQ 54Introduction
In Java, a Sub class inherits all instance variables and methods from which class ?
ADerived class
BChild class
CExtended class
DSuper class
Correct Answer: Option D
Note: null
MCQ 55Introduction
In Java, which step of creating an object from a class initialize the newly created object ?
AAll of these
BInstantiation
CDeclaration
DInitialization
Correct Answer: Option D
Note: null
MCQ 56Introduction
Which of the following is syntax of package ?
APackage {Package Name};
BPackage (Package Name);
CPackageΒ ;
DPackage [Package Name];
Correct Answer: Option C
Note: null
MCQ 57Introduction
In Java, which keyword is used to call the constructor of super class in the constructor of sub class ?
Asuper
Bextends
Cclass
Dsub
Correct Answer: Option D
Note: null
MCQ 58Introduction
Which of the following operator creates an object and returns its reference ?
Aobject
Bclass
Cdot (.)
Dnew
Correct Answer: Option D
Note: null
MCQ 59Introduction
A variable declared using class type can store what to an object ?
Areference
Bclass
Cheap
Dvariable
Correct Answer: Option D
Note: null
MCQ 60Introduction
Accessor method is known as what in Java ?
Aset
Bsetter
Cget
Dgetter
Correct Answer: Option D
Note: null
MCQ 61Introduction
In Java class, which operator is used to access instance variable and instance method via object ?
A, (comma)
B: (colon)
C. (dot)
D; (semicolon)
Correct Answer: Option C
Note: S-March-2020
MCQ 62Introduction
In Java, a Sub class can be derived from which class ?
AChild class
BSuper class
CExtended class
DOwner class
Correct Answer: Option B
Note: null
MCQ 63Introduction
In Java, which step a βnewβ keyword is used to create the object by allocating memory ?
AAll of these
BInstantiation
CInitialization
DDeclaration
Correct Answer: Option B
Note: null
MCQ 64Classification of variables declared in a class
Which type of variables are defined within a class but outside any method ?
AInstance variables
BLocal variables
CClass variables
DAll of these
Correct Answer: Option A
Note: null
MCQ 65Visibility modifiers for Access Control
Which of the following is the highest level of protection in Java ?
APackage
BPublic
CPrivate
DProvided
Correct Answer: Option C
Note: null
MCQ 66Inheritance
In Java, Child class can be referred to as which of the following ?
ASub class, Derived class, Extended class
BParent class, Super class, Base class
CParent class, Extended class, Base class
DSub class, Base class, Super class
Correct Answer: Option A
Note: null
MCQ 67Polymorphism(Method overloading)
Which of the following is the meaning of Polymorphism ?
AUser forms
BVirtual forms
CMany forms
DSingle form
Correct Answer: Option C
Note: null
MCQ 68Accessing instance variables and calling instance methods
What is the associativity of . (dot) operator which is used to access instance variable ?
ALower to Upper
BUpper to Lower
CRight to Left
DLeft to Right
Correct Answer: Option D
Note: null
MCQ 69Visibility modifiers for Access Control
Which level of protection is used to allow the access only to sub classes or to share with the methods declared as βfriendβ in Java ?
APublic
BPrivate
CProtected
DPackage
Correct Answer: Option C
Note: null
MCQ 70Introduction
What does a class contain?
AData & Method
BData & Program code
COnly Data
DOnly program code
Correct Answer: Option B
Note: null
MCQ 71Introduction
What does a class contain?
AData & Method
BData & Program code
COnly Data
DOnly program code
Correct Answer: Option B
Note: null
MCQ 72Introduction
In class, Data is referred to as β¦β¦β¦β¦.
AAttributes
Bbehavior
Cstate
Dfunction
Correct Answer: Option A
Note: null
MCQ 73Introduction
In Java functions referred to as β¦β¦β¦β¦..
AAttributes
Bbehavior
Cstate
DMethod
Correct Answer: Option D
Note: null
MCQ 74Introduction
When a program contains 2 or more classes, only one class can contain the β¦β¦β¦β¦method.
Amain( )
BString( )
Cclass
Dprivate
Correct Answer: Option A
Note: null
MCQ 75Introduction
What is a template for multiple objects with similar features?
Aclass
BMethod
CAttribute
DBehavior
Correct Answer: Option A
Note: null
MCQ 76Introduction
In Java, a class is defined using which keyword?
APublic
Bclass
Cname
DAttribute
Correct Answer: Option B
Note: null
MCQ 77Introduction
In Java, a class is defined using which keyword?
APublic
Bclass
Cname
DAttribute
Correct Answer: Option B
Note: null
MCQ 78Introduction
Every class is made up with how many components?
Aattribute
Bbehavior
Cstate
DBoth a and b
Correct Answer: Option D
Note: null
MCQ 79Introduction
What are defined by variables in a class?
ABehavior
BAttribute
CState
Dmethods
Correct Answer: Option B
Note: null
MCQ 80Introduction
Which of the following is used to access or modify attributes?
AMethod
Bclass
CAttribute
DBehavior
Correct Answer: Option A
Note: null
MCQ 81Introduction
What is defined by method in a class?
AMethod
Bclass
CAttribute
DBehavior
Correct Answer: Option C
Note: null
MCQ 82Introduction
Write the right steps to create an object.
ADeclaration
BInstantiation
CInitialization.
DAll of these
Correct Answer: Option C
Note: null
MCQ 83Introduction
Declaring a variable does not create an β¦β¦β¦β¦.in Java.
AObject
Bmethod
CAttribute
DBehavior
Correct Answer: Option A
Note: null
MCQ 84Introduction
Variable of class type are also referred to as β¦β¦β¦β¦variables.
Areference
BGlobal
CAllocated
DConstant
Correct Answer: Option A
Note: null
MCQ 85Introduction
Which operator allocates the memory for an object and returns the address of object?
Anew
Bobject
Cclass
DMethod
Correct Answer: Option A
Note: null
MCQ 86Introduction
What do we call the address of the memory location where the object is stored?
AAddress
BReference
CAllocated
DConstant
Correct Answer: Option B
Note: null
MCQ 87Introduction
What do we call the special portion of memory where the objects live?
AReference
BHeap
CAddress
DStructure
Correct Answer: Option B
Note: null
MCQ 88Introduction
When an object is created, then which special method is executed to perform initial task?
AConstructor
BMethod
CAttributes
DFunction
Correct Answer: Option A
Note: null
MCQ 89Introduction
Which constructor is called with empty parentheses without arguments?
AObject constructor
Bdefault constructor
CMethod
DParameterized constructor
Correct Answer: Option B
Note: null
MCQ 90Introduction
When statement βr1=new Room( );β is executed then what is stored in r1?
AAddress of an object
BReference of an object
CHeap
DAll of these
Correct Answer: Option A
Note: null
MCQ 91Introduction
Which of the following is the correct syntax to declare and create an object in a single line?
ARoom r2=new Room( );
Broom r=room();
CRoom r1=room()
DRoom =Room(new);
Correct Answer: Option A
Note: null
MCQ 92Introduction
In Java, which of the following looks for unused objects and reclaims the memory that those objects are using?
AVariable collector
BGarbage collector
CClass collector
DObject collector
Correct Answer: Option B
Note: null
MCQ 93Introduction
In Java, creating an object with βnewβ key word is also called object β¦β¦β¦β¦β¦..
ADeclaration
BInstantiation
CInitialization
DAll of these
Correct Answer: Option B
Note: null
MCQ 94Introduction
Which type of variables is created at the time of creating an object and stay throughout the life of the ojects ?
ALocal
BInstance
CStatic
Dnull
Correct Answer: Option B
Note: null
MCQ 95Introduction
Which type of variable is define by the attributes of an object?
ALocal
BInstance
CStatic
Dnull
Correct Answer: Option B
Note: null
MCQ 96Introduction
In Java,β¦β¦β¦β¦..can be defined inside a class only.
Amethod
Bclass
CAttributes
DState
Correct Answer: Option A
Note: null
MCQ 97Introduction
All instance of class are allocated memory in which data structure?
Aheap
Bconstructor
CInherit
DOverload
Correct Answer: Option A
Note: null
MCQ 98Introduction
What is the associativity of dot operator
AL to R
BR to L
CT to B
DB to T
Correct Answer: Option A
Note: null
MCQ 99Introduction
Instance variables and instance methods can be referred by using β¦β¦β¦β¦.operators.
Adot ( . )
Bcomma( β )
Csemicolon( ; )
Dcolon( : )
Correct Answer: Option A
Note: null
MCQ 100Introduction
Referring instance variable or invoking method with null reference will give β¦β¦β¦...
Aoutput
BError
CObject
DClass
Correct Answer: Option B
Note: null
MCQ 101Introduction
Instance methods are used to define β¦β¦β¦β¦of an object.
AAttribute
BBehavior
Cstate
DFunctions
Correct Answer: Option B
Note: null
MCQ 102Introduction
Variable belongs to a class and not to an β¦β¦β¦β¦
AAttribute
BObject
CBehavior
Dmethod
Correct Answer: Option B
Note: null
MCQ 103Introduction
Which variables are called the class variable can be declared within class using static keyword before data type ?
AMemory
Bstatic
Clocal
Dinstance
Correct Answer: Option B
Note: null
MCQ 104Introduction
What do we call the variables that defined inside methods or blocks?
ALocal variable
BClass variable
CStatic variable
DInstance variable
Correct Answer: Option A
Note: null
MCQ 105Introduction
What do we call the variables that are defined within a class but outside any method?
AInstance variable
BClass variable
CStatic variable
DLocal variable
Correct Answer: Option A
Note: null
MCQ 106Introduction
Which variables are initialized with default value?
AInstance and class variable
BClass and local variables
Cclass and static variable
DStatic and Instance variable
Correct Answer: Option A
Note: null
MCQ 107Introduction
What do we call the term where different forms of methods are used with same name?
APolymorphism
BInheritance
Cconstructor
DAggregation
Correct Answer: Option A
Note: null
MCQ 108Introduction
The word β¦β¦β¦β¦β¦..means many forms.
APolymorphism
BInheritance
Cconstructor
DAggregation
Correct Answer: Option A
Note: null
MCQ 109Introduction
Which term means, different methods that have the same name but a different signature?
AMethod overloading
BInheritance
CConstructor
DAggregation
Correct Answer: Option A
Note: null
MCQ 110Introduction
Which of the following are the steps to create Polymorphism?
AMethod name
Btype of return value
Ca list of parameters
DAll of these
Correct Answer: Option D
Note: null
MCQ 111Introduction
What do we call the special method that is invoked when a new object is created?
APolymorphism
BConstructor
CInheritance
DAll of these
Correct Answer: Option B
Note: null
MCQ 112Introduction
Every class is having its default β¦β¦β¦β¦β¦
APolymorphism
BConstructor
CInheritance
DAll of these
Correct Answer: Option B
Note: null
MCQ 113Introduction
Which type of constructor does not take any argument?
ADefault
BParameterized
CMulti level
DMultiple
Correct Answer: Option C
Note: null
MCQ 114Introduction
Which is mainly designed to perform initializing actions?
AConstructor
BPolymorphism
CInheritance
DAll of these
Correct Answer: Option A
Note: null
MCQ 115Introduction
Constructor does not have β¦β¦β¦β¦β¦β¦.type.
Areturn
Bvoid( )
Cdefault
DAll of these
Correct Answer: Option A
Note: null
MCQ 116Introduction
Constructor is invoked implicitly only when an object is constructed using β¦β¦β¦..operator.
Anew
Bdefault
Cnew( )
D+
Correct Answer: Option A
Note: null
MCQ 117Introduction
Constructor must have the β¦β¦β¦β¦..name as class name.
Asame
Bnew name
Cdifferent
Ddefault
Correct Answer: Option A
Note: null
MCQ 118Introduction
Which of the following is the correct for the Constructor? i. Constructor must have the same name as class name. ii. Constructor does not have return type. iii. Constructor is invoked implicitly only when an object is constructed using new operator. iv. Constructor can not be invoked explicitly else
Ai, ii, iii, iv
Bi, ii, v, iii
Cv, i ,iv, iii
Dv, i, iii,,iv
Correct Answer: Option A
Note: null
MCQ 119Introduction
Access control means to control β¦β¦β¦.
Avisibility
Bprogram
CObjects
DAttributes
Correct Answer: Option A
Note: null
MCQ 120Introduction
In absence of user define constructor in a class, objects are constructed using which type of constructor?
ADefault
Bno β argument
CParameterized
Dmultilevel
Correct Answer: Option A
Note: null
MCQ 121Introduction
Which of the following is known as a user-defined no-argument constructor?
A{ } [ ];
B( ) {};
C( ) [ ];
D[ ] ( );
Correct Answer: Option B
Note: null
MCQ 122Introduction
Which of the following is the meaning of polymorphism?
ASingle form
BPost text
CPost morphism
DMany forms
Correct Answer: Option D
Note: null
MCQ 123Introduction
What is known as visibility modifier?
AAccess modifier
BConstructor
CPolymorphism
DInheritance
Correct Answer: Option A
Note: null
MCQ 124Introduction
Which of the following is a part of Four Pβs Protection in Java?
APrivate
BPackage, Protected
CPublic
DAll of these
Correct Answer: Option D
Note: null
MCQ 125Introduction
Which of the following is not a part of Four Pβs protection in Java?
Apublic
Bpackage
Cprivate
Dprovided
Correct Answer: Option D
Note: null
MCQ 126Introduction
Which type of access modifiers are used before the type of variable or method?
Apublic
Bprotected
Cprivate
DAll of these
Correct Answer: Option D
Note: null
MCQ 127Introduction
Which of the following access modifier is used to organized classes?
APublic
BPackage
CPrivate
DProtected
Correct Answer: Option B
Note: null
MCQ 128Introduction
Write down the syntax of package.
Apackage <packageName>;
Bpackage (packageName)
Cpackage [packageName]
DAll of the above
Correct Answer: Option A
Note: null
MCQ 129Introduction
Which access modifier provides visibility to classes defined in the other package?
Apublic
Bpackage
CPrivate
DProtected
Correct Answer: Option A
Note: S-March-2020
MCQ 130Introduction
To provide public access, which keyword type before method or variable type?
APrivate
BPublic
CProtected
DPackage
Correct Answer: Option B
Note: null
MCQ 131Introduction
Public variables and methods are β¦β¦β¦β¦..anywhere.
Avisible
Binvisible
Coutside
Dinside
Correct Answer: Option A
Note: null
MCQ 132Introduction
Which of the following is the highest level of protection in Java?
APrivate
BPackage
CPublic
DProtected
Correct Answer: Option A
Note: null
MCQ 133Introduction
What is the other name of mutator method?
Aset
Bsetter
Cgetter
Dget
Correct Answer: Option B
Note: null
MCQ 134Introduction
What is the other name for accessor method.
Aget
Bgetter
Csetter
Dset
Correct Answer: Option B
Note: null
MCQ 135Introduction
Which level of protection is used to allow the access only to subclasses or to share with the methods declared as βfriendβ?
Apublic
Bprotected
CPrivate
DPackage
Correct Answer: Option B
Note: null
MCQ 136Introduction
Which keyword is used to share data of private class?
Afriend
Bextends
Cthrow
Dget
Correct Answer: Option A
Note: null
MCQ 137Introduction
Which protection level cannot be seen by any other class?
APrivate
BProtected
CPublic
DPackage
Correct Answer: Option A
Note: null
MCQ 138Introduction
If we want private data to be used by other, then which method is used?
Aaccessor
Baccess
Cexcess
Dmutator
Correct Answer: Option A
Note: null
MCQ 139Introduction
If we want to allow private data to be modified by others, then which method is used?
Aaccessor
Baccess
Cexcess
Dmutator
Correct Answer: Option D
Note: null
MCQ 140Introduction
Which of the following prefix is utilize for conventionally naming of mutator method?
Await
Bset
Cget
Dtake
Correct Answer: Option B
Note: null
MCQ 141Introduction
Which of the following prefix is utilize for conventionally naming of accessor method?
Await
Bset
Cget
Dtake
Correct Answer: Option C
Note: null
MCQ 142Introduction
If we want to allow other methods to read only the data value, then which method is used?
Agetter
Bget
Cset
Dsetter
Correct Answer: Option A
Note: null
MCQ 143Introduction
If we want to allow other methods to modify the data value, then which method is used?
Agetter
Bget
Cset
Dsetter
Correct Answer: Option D
Note: null
MCQ 144Introduction
Find the valid getter or setter names from the list. (1) getLength (2) GetLength (3) getlength (4) setLength (5)SetLength (6) setAttribute
A1,3,4,6
B1,4,6
C1,2,3,4
D1,3,4,6
Correct Answer: Option B
Note: null
MCQ 145Introduction
Which facility allows us to build new class with added capabilities by extending existing class?
AInheritance
BConstructor
CPolymorphism
DAggregation
Correct Answer: Option A
Note: null
MCQ 146Introduction
Inheritance model is based on which type of relationship between two classes?
Ahas - a β part
Bis β a β kind
Cis-a-kind-of
Dboth b or c
Correct Answer: Option D
Note: null
MCQ 147Introduction
In inheritance, Parent class is also referred to asβ¦β¦β¦β¦.class.
Asuper
Bbase
Csub
Dboth a and b
Correct Answer: Option D
Note: null
MCQ 148Introduction
In inheritance, Child class is also referred to as β¦β¦β¦β¦..class.
Asub
Bderived
Cextended
DAll of these
Correct Answer: Option D
Note: null
MCQ 149Introduction
In which class common features are kept?
Asuper
Bextended
Csub
DNone of above
Correct Answer: Option A
Note: null
MCQ 150Introduction
Which class inherits all instance variables and methods from super class, and it may have its own added variables and methods?
ABase class
BSubclass
CSub class
DNone of above
Correct Answer: Option B
Note: null
MCQ 151Introduction
What is not inherited in sub class?
AConstructor
BMethod
CPolymorphism
DSuper class
Correct Answer: Option A
Note: null
MCQ 152Introduction
Which keyword is used to create a subclass in the class definition?
Aderived
Bextends
CSuper
Dnew
Correct Answer: Option B
Note: null
MCQ 153Introduction
Which keyword is used to call the constructor of super class in the constructor of sub class?
Aextends
Bsuper
Cextends
Dnew
Correct Answer: Option B
Note: null
MCQ 154Introduction
When super class and sub class have methods with same signature, a super class method is said to be β¦β¦β¦β¦.. in the sub class.
Aoverloading
Boverridden
Coperator loading
DNone of above
Correct Answer: Option B
Note: null
MCQ 155Introduction
All instance variable and methods are inherited from super class to β¦β¦β¦β¦..class.
Asub
BParent
Csuper
Dnew
Correct Answer: Option A
Note: null
MCQ 156Introduction
Java does not support β¦β¦β¦β¦β¦.type of inheritances.
Amultiple
BSingle
Cmulti level
Dconstructor
Correct Answer: Option A
Note: null
MCQ 157Introduction
A subclass can be derived from only the β¦β¦β¦β¦..class.
ASuper
Bnew
CExtended
Dsub
Correct Answer: Option A
Note: null
MCQ 158Introduction
Which of the following are the construction of classes that incorporate other objects. They establish a βhas-aβ relationship between classes?
AComposition
Baggregation
CConstructor
DBoth a or b
Correct Answer: Option D
Note: G-March-2022
MCQ 159Introduction
Composition & aggregation establish which type of relationship between classes?
Ahas β a β part
Bhas β a
Cis-a-kind-of
DBoth a or b
Correct Answer: Option D
Note: null
MCQ 160Introduction
Which symbol is used in Inheritance?
AArrow
BCircle
CDiamond
DTriangle
Correct Answer: Option A
Note: null
MCQ 161Constructors
In java, which of the following can not be invoked explicitly elsewhere in the program?
Aclass
Bconstructor
Cclass variable
Ddisplay() method
Correct Answer: Option B
Note: G-March-2022
MCQ 162Introduction
In Java, in which steps of object creation, constructor is called to initialize the newly created object?
ADeclaration
BInstantiation
CInitialization
DModification
Correct Answer: Option C
Note: G-March-2022
MCQ 163Introduction
Which part of Java looks for unused objects and reclaims the memory that those objects are using?
Anew keyword
Bheap area
Cconstructor
Dgarbage collector
Correct Answer: Option D
Note: G-March-2022
MCQ 164Introduction
In Java, which kind of variables are allocated memory from heap area when an object is created?
AInstance variables
BLocal variables
CClass variables
DGlobal variables
Correct Answer: Option A
Note: G-March-2022
MCQ 165Introduction
In Java, which of the following returns a reference to an object that represents an instance of the class?
ASuper
BNew keyword
CExtends
DClass keyword
Correct Answer: Option B
Note: G-March-2022
MCQ 166Introduction
In Java, which of the following allows us to build new class with added capabilities by extending existing class?
AAccessor method
BMutator method
CInheritance
DConstructor
Correct Answer: Option C
Note: G-March-2022
MCQ 167Introduction
In Java, which of the following are the construction of classes that incorporate other objects?
Avariables and literals
Bnew keyword and class keyword
Caccessor and mutator methods
Dcomposition and aggregation
Correct Answer: Option D
Note: G-March-2022
MCQ 168Introduction
Use of which protection of Java will become more relevant when we use inheritance concept of object-oriented programming?
APublic
BPrivate
CProtected
DPackage
Correct Answer: Option C
Note: G-March-2022
MCQ 169Introduction
In Java, which of the following is a proper syntax to define class?
A
B
C
D
Correct Answer: Option D
Note: G-March-2022
MCQ 170Introduction
In Java, instance variables and instance methods are referred by using which operator?
Adot (.) operator
Bplus (+) operator
CHyphen (-) operator
DUnder score (_ ) operator
Correct Answer: Option A
Note: G-March-2022
MCQ 171Introduction
In Java; which of the following can not be invoked explicitly elsewhere in the program?
Aclass
Bconstructor
Cclass variables
Ddisplay ( ) method
Correct Answer: Option B
Note: G-March-2022
MCQ 172Introduction
Which kind of Java class variables are allocated memory from heap area when an object is created?
ALocal variables
BClass variables
CInstance variables
DStatic variables
Correct Answer: Option C
Note: G-May-2019
MCQ 173Introduction
In Java, which keyword is used to define class?
Anew
Bclass
Cstatic
Dauto
Correct Answer: Option B
Note: G-May-2019
MCQ 174Introduction
In Java, which keyword is used to define class methods?
Aclass
Bnew
Cint
Dstatic
Correct Answer: Option D
Note: G-May-2019
MCQ 175Introduction
In Java, which of the following is a special kind of method that is invoked when a new object is created?
AConstructor
BHeap
CGarbage collector
DVisibility modifier
Correct Answer: Option A
Note: G-May-2019
MCQ 176Introduction
In Java, which methods can be used to define behaviour of an object?
AClass Methods
BInstance Methods
CLocal Methods
DGlobal Methods
Correct Answer: Option B
Note: G-May-2019
MCQ 177Introduction
When methods of the super class and subclass have same name and signature, what are they called?
AOverloaded methods
BOverridden methods
CAbstracted methods
DLocal methods
Correct Answer: Option B
Note: G-May-2019
MCQ 178Introduction
In Java, in which step of creating an object, constructor is called to initialize the newly created object?
ADeclaration
BModification
CInstantiation
DInitialization
Correct Answer: Option D
Note: G-May-2019
MCQ 179Introduction
In Java, which level of protection is used to allow the access only to subclasses or to share with the methods declared as βfriendββ?
APublic
BPrivate
CProtected
DPackage
Correct Answer: Option C
Note: G-May-2019
MCQ 180Introduction
In switch statement of Java, which statement is executed when no match is found?
ABreak
BDefault
CContinue
DCase
Correct Answer: Option B
Note: G-May-2019
MCQ 181Introduction
Which of the following names is given to the existing class in object oriented terminology?
ASuper Class
BSub Class
CChild Class
DDerived Class
Correct Answer: Option A
Note: G-May-2019
MCQ 182Introduction
In Java, which method is used, when we want to allow private data to be used by others?
AAccessor
BMutator
CNew
DVoid
Correct Answer: Option B
Note: G-May-2019
MCQ 183Classification of variables declared in a class
In Java, which of the following are variables defined within a class but outside any method? .
Alocal variables
Binstance variables
Cclass variables
Dmain variables
Correct Answer: Option B
Note: G-March-2019
MCQ 184Introduction
Which of the following are fundamental parts of object-oriented programming?
Amethod and class
Bobject and class
Cobject and method
DNone of the given
Correct Answer: Option B
Note: null
MCQ 185Introduction
Which method is used to display attribute of βClassroomβ object?
Alist()
Bshow()
Cdisplay()
Dprint()
Correct Answer: Option B
Note: null
MCQ 186Introduction
An inheritance model refers to which of the following relationships?
Ais - a
Bhas - a
Chave β a
DAll of the given
Correct Answer: Option A
Note: null
MCQ 187Introduction
Which method is overridden in subclass when superclass and subclass have methods with same signature?
ASubclass
BSuperclass
CBoth A and B
DNone of the given
Correct Answer: Option B
Note: null
MCQ 188Introduction
Which of the following access modifier has no precise name?
APublic
BPrivate
CPackage
DProtection
Correct Answer: Option C
Note: null
MCQ 189Introduction
What does 'polymorphism' means in Java?
AMany forms.
BDifferent forms of methods with same name
CMethod overloading
DAll of the given
Correct Answer: Option D
Note: null
MCQ 190Introduction
A method in Java is created in ____________
Aan object
Bclass
Can array
Dstream
Correct Answer: Option B
Note: null
MCQ 191Introduction
Which of the following variable/s is/are initialized with default values?
Aclass
Binstance
Clocal
DBoth A and B
Correct Answer: Option D
Note: null
MCQ 192Introduction
In Java, ___________________ can be defined inside the class only.
AComment
Bmethod
Cloop
DNone of the given
Correct Answer: Option B
Note: null
MCQ 193Introduction
Default constructor is no more available in presence of ______________in a class.
Auser-defined constructor
Bloop
Cfunction
DNone of the given
Correct Answer: Option A
Note: null
MCQ 194Introduction
Which of the following defines attributes?
AMethod
BFunction
CVariable
DAll of the given
Correct Answer: Option C
Note: null
MCQ 195Introduction
Which variable/s is/are initialized with default values?
AInstance variable
BClass variable
CBoth A & B
DNone of the given
Correct Answer: Option C
Note: null
MCQ 196Introduction
Which class in Java contains all the features/ attributes of inheritance?
Asuper
Bsub
Cmain
DNone of the given
Correct Answer: Option A
Note: null
MCQ 197Introduction
What is used to invoke display() method within show() method of superclass?
AList.display()
BSuper.display()
CSub.display()
DShow.display()
Correct Answer: Option B
Note: null
MCQ 198Introduction
The scope of which access modifier is narrower than public variables?
Aprivate
Bprotected
Cpackage
DAll of the given
Correct Answer: Option C
Note: null
MCQ 199Introduction
In Java, when different methods are created using the same name, it is called _____________
Aconstructor
Binheritance
Cpolymorphism
Dmultiple method
Correct Answer: Option C
Note: null
MCQ 200Introduction
In Java, by which other name an object is known as ?
AVariable
BMethod
CClass instance
DClass parameter
Correct Answer: Option C
Note: null
MCQ 201Introduction
In Java, a class name can be used to specify _________________________
Atype of variable in a declaration statement
Bthe type of a formal parameter
Cthe return type of a function
DAll of the given
Correct Answer: Option D
Note: null
MCQ 202Introduction
The best way to provide data encapsulation is to make as much data as ___________ as possible.
Apackage
Bprotected
Cprivate
Dpublic
Correct Answer: Option C
Note: null
MCQ 203Introduction
The ___________________ returns a reference to an object that represents an instance of the class.
Anew keyword
Bconstructor
Cvariable
DNone of the given
Correct Answer: Option A
Note: null
MCQ 204Introduction
Every Java class is made up of ________________ component.
Aattribute
Bbehaviour
CA or B
DNone of the given
Correct Answer: Option C
Note: null
MCQ 205Introduction
Which variables are defined inside methods or blocks?
Ainstance variable
Blocal variable
CBoth A and B
DNone of the given
Correct Answer: Option B
Note: null
MCQ 206Introduction
In inheritance, a __________inherits all instance variables and methods from superclass.
Asuperclass
Bsubclass
Cmaster class
Dslave class
Correct Answer: Option B
Note: null
MCQ 207Introduction
Which of the following in Java establish a 'has-a' relationship between classes?
AAggregation
BComposition
CBoth A and B
DNone of the given
Correct Answer: Option C
Note: null
MCQ 208Introduction
The variable or method of which access modifier can be accessed from anywhere in Java?
Apublic
Bprivate
Cpackage
DAll of the given
Correct Answer: Option C
Note: null
MCQ 209Introduction
Which of the following give initial value to the variable?
AMethod
Bconstructor
Cvariable
DMethod overloading
Correct Answer: Option B
Note: null
MCQ 210Introduction
In object-oriented programming languages, creating an object is called __________________
Aobject instantiation
Bobject creation
Cobject modification
DAll of the given
Correct Answer: Option A
Note: null
MCQ 211Introduction
Which of the following adds constructor without variable in Java?
ARoom {}();
BRoom [] {};
CRoom <> {};
DRoom ( ){};
Correct Answer: Option D
Note: null
MCQ 212Introduction
Which of the following is/are required to create an object from a class?
ADeclaration
BInstantiation
CInitialization
DAll of the given
Correct Answer: Option D
Note: null
MCQ 213Introduction
Which of the following access modifiers are used before the type of variable or method?
Apublic
Bprotected
Cprivate
DAll of the given
Correct Answer: Option D
Note: null
MCQ 214Introduction
Which keyword is used to create the object from Java class?
Anew
Bobj
Ccreate
DNone of the given
Correct Answer: Option A
Note: null
MCQ 215Introduction
Which variable/s is/are defined within a class but outside any method?
ALocal
BGlobal
CInstance
DAll of the given
Correct Answer: Option C
Note: null
MCQ 216Introduction
Which keyword is used to create a subclass in the class definition?
Asub
Bcreate
Cbelow
Dextends
Correct Answer: Option D
Note: null
MCQ 217Introduction
When a class in a Java inherits the objects of other class, it is known as __________________
Asubclass
Bsuperclass
Ccontainer class
Dmaster class
Correct Answer: Option C
Note: null
MCQ 218Introduction
Which of the following access modifier is used to access only subclasses?
Aprivate
Bpublic
Cpackage
Dprotected
Correct Answer: Option D
Note: null
MCQ 219Introduction
Which of the following is also known as no-argument constructors?
ADefault constructor
BNull constructor
CAccess constructor
DAll of the given
Correct Answer: Option A
Note: null
MCQ 220Introduction
In Java, the actual data is contained inside the ______________
Aclass
Bobject
Cmethod
DAll of the given
Correct Answer: Option B
Note: null
MCQ 221Introduction
Which variables are not initialized by default values?
ALocal
BClass
CInstance
DAll of the given
Correct Answer: Option A
Note: null
MCQ 222Introduction
The method's signature is a combination of ________________
Aname of method
Bthe type of return value
Ca list of parameters
DAll of the given
Correct Answer: Option D
Note: null
MCQ 223Introduction
_____________ are special methods with same name as class name, no arguments and no return type.
AConstructor
BInstance variable
CPackage
DNone of the given
Correct Answer: Option A
Note: null
MCQ 224Introduction
Which of the following keyword is used to create an object?
Anew
Bcreate
Cmake
Dinsert
Correct Answer: Option A
Note: null
MCQ 225Introduction
Which of the following variables are allocated memory from heap area when an object is instantiated?
Aglobal
Blocal
Cinstance
Dclass
Correct Answer: Option C
Note: null
MCQ 226Introduction
Which of the following keyword is used to invoke a superclass constructor in subclass constructor?
Asup
Bsuper
Ckey
Dcall
Correct Answer: Option B
Note: null
MCQ 227Introduction
What is the other name of 'Mutator Method' ?
Amutator
Baccess
Cgetter
Dsetter
Correct Answer: Option D
Note: null
MCQ 228Introduction
Which of the following access modifier provides highest level of protection in Java?
Apublic
Bprivate
Cpackage
DAll of the given
Correct Answer: Option B
Note: null
MCQ 229Introduction
In Java, an attempt to create an object using constructor without argument results in _____
A0
B1
C-1
Derror
Correct Answer: Option D
Note: null
MCQ 230Introduction
What is stored in heap?
Aclass
Bobject
Cclass address
DNone of the given
Correct Answer: Option B
Note: null
MCQ 231Introduction
Instance variables and instance methods are accessed via __________
A.
B>
C<
D?
Correct Answer: Option A
Note: null
MCQ 232Introduction
Which of the following can be accessed from instance methods?
AInstance variable
BClass variable
CClass methods
DAll of the given
Correct Answer: Option D
Note: null
MCQ 233Introduction
In Java, an attempt to create an object using constructor without arguments compiler ________
Areturns error
Buses default constructor
Ccreates new constructor
DNone of the given
Correct Answer: Option A
Note: null
MCQ 234Introduction
What is heap?
ASpecial portion of memory
BMixture of memory
CKeyword in java
DAll of the given
Correct Answer: Option A
Note: null
MCQ 235Introduction
Which variables are defined within a class outside any method and with the static keyword?
ALocal variable
BInstance variable
CBoth A and B
DClass variable
Correct Answer: Option D
Note: null
MCQ 236Introduction
Which variable can be accessed without creating an instance of a class?
Astatic variable
Bobject variable
Cglobal variable
DAll of the given
Correct Answer: Option A
Note: null
MCQ 237Introduction
What is the other name of Accessor method?
Agetter
Bsetter
Cinput
Doutput
Correct Answer: Option A
Note: null
MCQ 238Introduction
Which access modifier provides the narrowest visibility?
APackage
BPublic
CPrivate
DProtected
Correct Answer: Option C
Note: null
MCQ 239Introduction
Which of the following modifier is used to organize classes?
APublic
BPrivate
CProtected
DPackage
Correct Answer: Option D
Note: null
MCQ 240Introduction
Which of the following is performed by constructor when an object of class is created?
AInitializing actions
BMemory allocation
CBoth A and B
DNone of the given
Correct Answer: Option C
Note: null
MCQ 241Introduction
__________variables are allocated memory only once per class and is shared by all its objects.
Aclass
Binstance
Clocal
DAll of the given
Correct Answer: Option A
Note: null
MCQ 242Introduction
Which of the following is accessible from other source files and packages?
Apublic variable
Bpublic method
CBoth A and B
Dpackage variable
Correct Answer: Option C
Note: null
MCQ 243Introduction
Access modifiers are also known as __________
Avisibility modifiers
Bprivacy modifiers
Cprotocol modifiers
Dprogram modifiers
Correct Answer: Option A
Note: null
MCQ 244Constructors
which Is a special kind of method that is invoked when a new object is created ?
Alocal
Binstance
Cconstructors
Dstatic
Correct Answer: Option C
Note: GSEB Commerce Oct-2020
MCQ 245Visibility modifiers for Access Control
Which of the following level of protection is used to allow the access only to subclasses or to share with friend methods?
Aprotected
Bpublic
Cpackage
Dprivate
Correct Answer: Option A
Note: GSEB Commerce Oct-2020
MCQ 246Class variables and class methods
What is the name of variables of class type refferd to as?
Arelated
Bdynamic
Crefernce
Dall of the above
Correct Answer: Option C
Note: GSEB Commerce Oct-2020
MCQ 247Class in Java
How many components are used to made up every class in java ?
A1
B2
C3
D4
Correct Answer: Option B
Note: GSEB Commerce Oct-2020
MCQ 248Objects
Which of the following steps are required for creating an object from a class?
ADeclaration, Instantiation,Initialization
BDeclaration, Initialization, Instantiation
CInstantiation, Initialization, Declaration
DInitialization, Instantiation, Declaration
Correct Answer: Option A
Note: GSEB Commerce Oct-2020
MCQ 249Classification of variables declared in a class
In java, which variables are defined with static keyboard ?
AClass
BInstance
CLocal
DAll of the above
Correct Answer: Option A
Note: GSEB Commerce Oct-2020
MCQ 250Introduction
Which of the following is a special kind of method that is invoked when a new object is created ?
AClass
BInstance
CConstructor
DObject
Correct Answer: Option C
Note: S-March-2020
MCQ 251Introduction
In Java, which step is followed to create an object from a class ?
ADeclaration
BAll of these
CInitialization
DInstantiation
Correct Answer: Option B
Note: S-March-2020
MCQ 252Introduction
Which access modifier provides visibility to classes defined in the other package?
Apublic
Bpackage
CPrivate
DProtected
Correct Answer: Option A
Note: S-March-2020
MCQ 253Constructors
In java, which of the following can not be invoked explicitly elsewhere in the program?
Aclass
Bconstructor
Cclass variable
Ddisplay() method
Correct Answer: Option B
Note: G-March-2022
MCQ 254Introduction
In Java, in which steps of object creation, constructor is called to initialize the newly created object? Compiled by Nuzhat Memon 15
ADeclaration
BInstantiation
CInitialization
DModification
Correct Answer: Option C
Note: G-March-2022
MCQ 255Introduction
Which part of Java looks for unused objects and reclaims the memory that those objects are using?
Anew keyword
Bheap area
Cconstructor
Dgarbage collector
Correct Answer: Option D
Note: G-March-2022
MCQ 256Introduction
In Java, which kind of variables are allocated memory from heap area when an object is created?
AInstance variables
BLocal variables
CClass variables
DGlobal variables
Correct Answer: Option A
Note: G-March-2022
MCQ 257Introduction
In Java, which of the following returns a reference to an object that represents an instance of the class?
ASuper
BNew keyword
CExtends
DClass keyword
Correct Answer: Option B
Note: G-March-2022
MCQ 258Introduction
In Java, which of the following allows us to build new class with added capabilities by extending existing class?
AAccessor method
BMutator method
CInheritance
DConstructor
Correct Answer: Option C
Note: G-March-2022
MCQ 259Introduction
In Java, which of the following are the construction of classes that incorporate other objects?
Avariables and literals
Bnew keyword and class keyword
Caccessor and mutator methods
Dcomposition and aggregation
Correct Answer: Option D
Note: G-March-2022
MCQ 260Introduction
Use of which protection of Java will become more relevant when we use inheritance concept of object-oriented programming?
APublic
BPrivate
CProtected
DPackage
Correct Answer: Option C
Note: G-March-2022
MCQ 261Introduction
In Java, instance variables and instance methods are referred by using which operator?
Adot (.) operator
Bplus (+) operator
CHyphen (-) operator
DUnder score (_ ) operator
Correct Answer: Option A
Note: G-March-2022
MCQ 262Introduction
In Java; which of the following can not be invoked explicitly elsewhere in the program?
Aclass
Bconstructor
Cclass variables
Ddisplay ( ) method
Correct Answer: Option B
Note: G-March-2022
MCQ 263Introduction
Which kind of Java class variables are allocated memory from heap area when an object is created?
ALocal variables
BClass variables
CInstance variables
DStatic variables
Correct Answer: Option C
Note: G-May-2019
MCQ 264Introduction
In Java, which keyword is used to define class?
Anew
Bclass
Cstatic
Dauto
Correct Answer: Option B
Note: G-May-2019
MCQ 265Introduction
In Java, which keyword is used to define class methods?
Aclass
Bnew
Cint
Dstatic
Correct Answer: Option D
Note: G-May-2019
MCQ 266Introduction
In Java, which of the following is a special kind of method that is invoked when a new object is created?
AConstructor
BHeap
CGarbage collector
DVisibility modifier
Correct Answer: Option A
Note: G-May-2019
MCQ 267Introduction
When methods of the super class and subclass have same name and signature, what are they called?
AOverloaded methods
BOverridden methods
CAbstracted methods
DLocal methods
Correct Answer: Option B
Note: G-May-2019
MCQ 268Introduction
In Java, in which step of creating an object, constructor is called to initialize the newly created object?
ADeclaration
BModification
CInstantiation
DInitialization
Correct Answer: Option D
Note: G-May-2019
MCQ 269Introduction
In switch statement of Java, which statement is executed when no match is found?
ABreak
BDefault
CContinue
DCase
Correct Answer: Option B
Note: G-May-2019
MCQ 270Introduction
Which of the following names is given to the existing class in object oriented terminology?
ASuper Class
BSub Class
CChild Class
DDerived Class
Correct Answer: Option A
Note: G-May-2019
MCQ 271Introduction
In Java, which method is used, when we want to allow private data to be used by others?
AAccessor
BMutator
CNew
DVoid
Correct Answer: Option B
Note: G-May-2019
MCQ 272Objects
Which of the following steps are required for creating an object from a class?
ADeclaration, Instantiation,Initialization
BDeclaration, Initialization, Instantiation
CInstantiation, Initialization, Declaration
DInitialization, Instantiation, Declaration
Correct Answer: Option A
Note: GSEB Commerce Oct-2020
MCQ 273Introduction
In Java, which keyword is used to create the object by allocating memory ?
Asuper
Badd
Cnew
Dclass
Correct Answer: Option C
Note: S-March-2020
MCQ 274Introduction
In Java, a class is defined using which keyword ?
Aclass
BCLASS
CAll of these
DClass
Correct Answer: Option A
Note: null
MCQ 275Introduction
In Java, how many levels of visibility modifiers are available for access control ?
A3
B2
C5
D4
Correct Answer: Option D
Note: null
MCQ 276Introduction
If we want to make visible to all the classes outside the class, where method or variable is visible to class, which type of access modifier is used ?
AProtected
BPrivate
CPackage
DPublic
Correct Answer: Option D
Note: null
MCQ 277Introduction
Accessor method is known as what in Java ?
Aset
Bsetter
Cget
Dgetter
Correct Answer: Option D
Note: null
MCQ 278Introduction
In Java class, which operator is used to access instance variable and instance method via object ?
A, (comma)
B: (colon)
C. (dot)
D; (semicolon)
Correct Answer: Option C
Note: S-March-2020
MCQ 279Introduction
Every class is made up with how many components?
Aattribute
Bbehavior
Cstate
DBoth a and b
Correct Answer: Option D
Note: null
MCQ 280Introduction
In Java, which of the following looks for unused objects and reclaims the memory that those objects are using?
AVariable collector
BGarbage collector
CClass collector
DObject collector
Correct Answer: Option B
Note: null
MCQ 281Introduction
All instance of class are allocated memory in which data structure?
Aheap
Bconstructor
CInherit
DOverload
Correct Answer: Option A
Note: null
MCQ 282Introduction
Instance methods are used to define β¦β¦β¦β¦of an object.
AAttribute
BBehavior
Cstate
DFunctions
Correct Answer: Option B
Note: null
MCQ 283Introduction
Constructor does not have β¦β¦β¦β¦β¦β¦.type.
Areturn
Bvoid( )
Cdefault
DAll of these
Correct Answer: Option A
Note: null
MCQ 284Introduction
Constructor must have the β¦β¦β¦β¦..name as class name.
Asame
Bnew name
Cdifferent
Ddefault
Correct Answer: Option A
Note: null
MCQ 285Introduction
Public variables and methods are β¦β¦β¦β¦..anywhere.
Avisible
Binvisible
Coutside
Dinside
Correct Answer: Option A
Note: null
MCQ 286Introduction
In inheritance, Child class is also referred to as β¦β¦β¦β¦..class.
Asub
Bderived
Cextended
DAll of these
Correct Answer: Option D
Note: null
MCQ 287Introduction
Java does not support β¦β¦β¦β¦β¦.type of inheritances.
Amultiple
BSingle
Cmulti level
Dconstructor
Correct Answer: Option A
Note: null
MCQ 288Introduction
Composition & aggregation establish which type of relationship between classes?
Ahas β a β part
Bhas β a
Cis-a-kind-of
DBoth a or b
Correct Answer: Option D
Note: null
MCQ 289Introduction
In Java, which kind of variables are allocated memory from heap area when an object is created?
AInstance variables
BLocal variables
CClass variables
DGlobal variables
Correct Answer: Option A
Note: G-March-2022
MCQ 290Introduction
In Java, which of the following are the construction of classes that incorporate other objects?
Avariables and literals
Bnew keyword and class keyword
Caccessor and mutator methods
Dcomposition and aggregation
Correct Answer: Option D
Note: G-March-2022
MCQ 291Introduction
Use of which protection of Java will become more relevant when we use inheritance concept of object-oriented programming?
APublic
BPrivate
CProtected
DPackage
Correct Answer: Option C
Note: G-March-2022
MCQ 292Introduction
In Java, which keyword is used to define class methods?
Aclass
Bnew
Cint
Dstatic
Correct Answer: Option D
Note: G-May-2019
MCQ 293Introduction
When methods of the super class and subclass have same name and signature, what are they called?
AOverloaded methods
BOverridden methods
CAbstracted methods
DLocal methods
Correct Answer: Option B
Note: G-May-2019
MCQ 294Introduction
In Java, which level of protection is used to allow the access only to subclasses or to share with the methods declared as βfriendββ?
APublic
BPrivate
CProtected
DPackage
Correct Answer: Option C
Note: G-May-2019
MCQ 295Introduction
In switch statement of Java, which statement is executed when no match is found?
ABreak
BDefault
CContinue
DCase
Correct Answer: Option B
Note: G-May-2019
MCQ 296Introduction
The scope of which access modifier is narrower than public variables?
Aprivate
Bprotected
Cpackage
DAll of the given
Correct Answer: Option C
Note: null
MCQ 297Introduction
The best way to provide data encapsulation is to make as much data as ___________ as possible.
Apackage
Bprotected
Cprivate
Dpublic
Correct Answer: Option C
Note: null
MCQ 298Introduction
In inheritance, a __________inherits all instance variables and methods from superclass.
Asuperclass
Bsubclass
Cmaster class
Dslave class
Correct Answer: Option B
Note: null
MCQ 299Introduction
Access modifiers are also known as __________
Avisibility modifiers
Bprivacy modifiers
Cprotocol modifiers
Dprogram modifiers
Correct Answer: Option A
Note: null
MCQ 300Introduction
In Java, which step is followed to create an object from a class ?
ADeclaration
BAll of these
CInitialization
DInstantiation
Correct Answer: Option B
Note: S-March-2020
MCQ 301Introduction
In Java, in which step of creating an object, constructor is called to initialize the newly created object?
ADeclaration
BModification
CInstantiation
DInitialization
Correct Answer: Option D
Note: G-May-2019
MCQ 302Class variables and class methods
In Java, which keyword is used before data type to declare class variables?
Astatic
Bnew
Csuper
Dpublic
Correct Answer: Option A
Note: null
MCQ 303Visibility modifiers for Access Control
IF WE WANT TO MAKE VISIBLE TO ALL THE CLASSES OUTSIDE THE CLASS, WHICH TYPE OF ACCESS MODIFIER IS USED.
APROTECTED
BPACKAGE
CPUBLIC
DPRIVATE
Correct Answer: Option C
Note: null
MCQ 304Methods
FROM THE FOLLOWING WHICH OPREATOR IS USED TO ACCESS INSTANCE VARIABLE AND INSTANCE IN JAVA.
A: (COLON)
B; (SEMICON)
C. (DOT)
D, ( COMMA)
Correct Answer: Option C
Note: null
MCQ 305Introduction
In Java, how many levels of visibility modifiers are available for access control ?
A3
B2
C5
D4
Correct Answer: Option D
Note: null
MCQ 306Introduction
If we want to allow other methods to modify the data value, then which method is used ?
Agetter
Bwrite
Csetter
Dreader
Correct Answer: Option C
Note: null
MCQ 307Introduction
Accessor method is known as what in Java ?
Aset
Bsetter
Cget
Dgetter
Correct Answer: Option D
Note: null
MCQ 308Polymorphism(Method overloading)
Which of the following is the meaning of Polymorphism ?
AUser forms
BVirtual forms
CMany forms
DSingle form
Correct Answer: Option C
Note: null
MCQ 309Visibility modifiers for Access Control
Which level of protection is used to allow the access only to sub classes or to share with the methods declared as βfriendβ in Java ?
APublic
BPrivate
CProtected
DPackage
Correct Answer: Option C
Note: null
MCQ 310Introduction
In class, Data is referred to as β¦β¦β¦β¦.
AAttributes
Bbehavior
Cstate
Dfunction
Correct Answer: Option A
Note: null
MCQ 311Introduction
In Java functions referred to as β¦β¦β¦β¦..
AAttributes
Bbehavior
Cstate
DMethod
Correct Answer: Option D
Note: null
MCQ 312Introduction
Every class is having its default β¦β¦β¦β¦β¦
APolymorphism
BConstructor
CInheritance
DAll of these
Correct Answer: Option B
Note: null
MCQ 313Introduction
Access control means to control β¦β¦β¦.
Avisibility
Bprogram
CObjects
DAttributes
Correct Answer: Option A
Note: null
MCQ 314Introduction
In inheritance, Child class is also referred to as β¦β¦β¦β¦..class.
Asub
Bderived
Cextended
DAll of these
Correct Answer: Option D
Note: null
MCQ 315Introduction
An inheritance model refers to which of the following relationships?
Ais - a
Bhas - a
Chave β a
DAll of the given
Correct Answer: Option A
Note: null
MCQ 316Introduction
Every Java class is made up of ________________ component.
Aattribute
Bbehaviour
CA or B
DNone of the given
Correct Answer: Option C
Note: null
MCQ 317Introduction
In Java, an attempt to create an object using constructor without argument results in _____
A0
B1
C-1
Derror
Correct Answer: Option D
Note: null
MCQ 318Objects
Which of the following steps are required for creating an object from a class?
ADeclaration, Instantiation,Initialization
BDeclaration, Initialization, Instantiation
CInstantiation, Initialization, Declaration
DInitialization, Instantiation, Declaration
Correct Answer: Option A
Note: GSEB Commerce Oct-2020
MCQ 319Introduction
All instance of class are allocated memory in which data structure?
Aheap
Bconstructor
CInherit
DOverload
Correct Answer: Option A
Note: null
MCQ 320Introduction
Constructor does not have β¦β¦β¦β¦β¦β¦.type.
Areturn
Bvoid( )
Cdefault
DAll of these
Correct Answer: Option A
Note: null
MCQ 321Introduction
In Java, in which step of creating an object, constructor is called to initialize the newly created object?