ā˜‘ MCQ PRACTICE

Java Programming Part 0

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

šŸ“š Java Programming
šŸ“– Part 0
šŸŽÆ MCQs

Java Programming - Part-0

1
Who invented Java Programming?
AGuido van Rossum
BJames Gosling
CDennis Ritchie
DBjarne Stroustrup
Correct Answer James Gosling
2
Which component is used to compile, debug and execute the java programs?
AJRE
BJIT
CJDK
DJVM
Correct Answer JDK
3
Which one of the following is not a Java feature?
AObject-oriented
BUse of pointers
CPortable
DDynamic and Extensible
Correct Answer Use of pointers
4
Which of these cannot be used for a variable name in Java?
Aidentifier & keyword
Bidentifier
Ckeyword
Dnone of the mentioned
Correct Answer keyword
5
Which of the following is a type of polymorphism in Java Programming?
AMultiple polymorphism
BCompile time polymorphism
CMultilevel polymorphism
DExecution time polymorphism
Correct Answer Compile time polymorphism
6
Which of these are selection statements in Java?
Abreak
Bcontinue
Cfor()
Dif()
Correct Answer if()
7
Which of the following is a superclass of every class in Java?
AArrayList
BAbstract class
CObject class
DString
Correct Answer Object class
8
Which one of the following is not an access modifier?
AProtected
BVoid
CPublic
DPrivate
Correct Answer Void
9
What is the numerical range of a char data type in Java?
A0 to 256
B-128 to 127
C0 to 65535
D0 to 32767
Correct Answer 0 to 65535
10
In which process, a local variable has the same name as one of the instance variables?
ASerialization
BVariable Shadowing
CAbstraction
DMulti-threading
Correct Answer Variable Shadowing
11
What do you mean by nameless objects?
AAn object created by using the new keyword.
BAn object of a superclass created in the subclass.
CAn object without having any name but having a reference.
DAn object that has no reference.
Correct Answer An object that has no reference.
12
Which option is false about the final keyword?
AA final method cannot be overridden in its subclasses.
BA final class cannot be extended.
CA final class cannot extend other classes.
DA final method can be inherited.
Correct Answer A final class cannot extend other classes.
13
In which memory a String is stored, when we create a string using new operator?
AStack
BString memory
CHeap memory
DRandom storage space
Correct Answer Heap memory
14
Which of the given methods are of Object class?
Anotify(), wait( long msecs ), and synchronized()
Bwait( long msecs ), interrupt(), and notifyAll()
Cnotify(), notifyAll(), and wait()
Dsleep( long msecs ), wait(), and notify()
Correct Answer notify(), notifyAll(), and wait()
15
What is the initial quantity of the ArrayList list?
A5
B10
C0
D100
Correct Answer 10
16
What is meant by the classes and objects that dependents on each other?
ATight Coupling
BCohesion
CLoose Coupling
DNone of the above
Correct Answer Tight Coupling
17
Which of this keyword must be used to inherit a class?
Asuper
Bthis
Cextent
Dextends
Correct Answer extends
18
A class member declared protected becomes a member of subclass of which type?
Apublic member
Bprivate member
Cprotected member
Dstatic member
Correct Answer private member
19
Which of these is correct way of inheriting class A by class B?
Aclass B + class A {}
Bclass B inherits class A {}
Cclass B extends A {}
Dclass B extends class A {}
Correct Answer class B extends A {}
20
Which of these keyword is used to refer to member of base class from a sub class?
Aupper
Bsuper
Cthis
Dnone
Correct Answer super
21
Which inheritance in java programming is not supported?
AMultiple inheritance using classes
BMultiple inheritance using interfaces
CMultilevel inheritance
DSingle inheritance
Correct Answer Multiple inheritance using classes
22
Which of these keywords can be used to prevent inheritance of a class?
Asuper
Bconstant
Cclass
Dfinal
Correct Answer final
23
Which of these class relies upon its subclasses for complete implementation of its methods?
AObject class
Babstract class
CArrayList class
DNone of the mentioned
Correct Answer abstract class
24
Properties are implemented using ___ in Java.
AMethods
BVariables
CInterfaces
DAll the above
Correct Answer Variables
25
Creating an object from a class is also called ____.
AInitializing
BInstantiating
CInterfacing
DNone of the above
Correct Answer Instantiating
26
An object is created at __ time in Java.
ACompile-time
BRun time
CAssembling time
DNone of the above
Correct Answer Run time
27
Which of the following statements is a valid declaration of an object that belongs to "MyClass"?
AMyClass obj = new MyClass();
BMyClass obj = new MyClass;
Cobj = new MyClass();
Dnew MyClass obj;
Correct Answer MyClass obj = new MyClass();
28
Which of these operators is used to allocate memory for an object?
Amalloc
Balloc
Cnew
Drealloc
Correct Answer new
29
____________________ is the address of the memory location where the object is stored
AMemory
BVariable
CReference
DNone
Correct Answer Reference
30
There is a special portion of memory called the _____________ where the object lives.
AHeap
BPile
CStack
DAll of these
Correct Answer Heap
31
When an object is created, in addition of allocating memory, a special method called ________________ is executed to perform initial task.
AFunction
BConstructor
CClass
DMethod
Correct Answer Constructor
32
Every ________________ has it's own set of data
AClass
BVariable
COperator
DObject
Correct Answer Object
33
Java has a garbage collector that looks for unused _____________ and reclaims the memory that those objects are using.
AObjects
BVariables
CCells
DMemory spaces
Correct Answer Objects
34
Protection of data is possible with the use of access __________________
AModifiers
BOperators
CMethods
DNone of these
Correct Answer Modifiers
35
_____________________ variables can be accessed without creating an instance of a class
Apublic
Bnew
Cstatic
Dprivate
Correct Answer static
36
Object-oriented programming languages provides reusability feature using _____________
Apolymorphism
BAbstraction
CInheritance
DEncapsulation
Correct Answer Inheritance
37
Inheritance models __________________ relationship between two classes.
Ais-a
Bits-a
Chas-a
Dis-at
Correct Answer is-a
38
___________________ refers more than one method having same name but different parameters?
AMethod overloading
BMethod overriding
CDuplicate methods
DAll
Correct Answer Method overloading
39
___________________ members are available as 'private' members in the inherited sub class
Apublic
Bprivate
Cprotected
Ddefault
Correct Answer protected
40
___________________ variables are variables defined within a class but outside any method.
AInstance
BPrivate
CLocal
DGlobal
Correct Answer Instance
41
Which of these jump statements can skip processing the remainder of the code in its body for a particular iteration?
Abreak
Breturn
Cexit
Dcontinue
Correct Answer continue
42
Which of the following is not a decision making statement?
Aif
Bif-else
Cswitch
Ddo-while
Correct Answer do-while
43
Which of these class is superclass of String and StringBuffer class?
Ajava.util
Bjava.lang
CArrayList
DNone of the mentioned
Correct Answer java.lang
44
Which of this method of class String is used to obtain a length of String object?
Aget()
BSizeof()
Clengthof()
Dlength()
Correct Answer length()
45
Which of these method of class String is used to extract a single character from a String object?
ACHARAT()
Bchatat()
CcharAt()
DChatAt()
Correct Answer charAt()
46
Which of these constructors is used to create an empty String object?
AString()
BString(void)
CString(0)
DNone of the mentioned
Correct Answer String()
47
Which of these method of class String is used to compare two String objects for their equality?
Aequals()
BEquals()
Cisequal()
DIsequal()
Correct Answer equals()
48
Which feature comes under compile time polymorphism?
AMethod overloading
BConstructor overloading
CMethod overriding
DBoth A and B
Correct Answer Both A and B
49
Final keyword in java is used with
Aclass
Bclass fields
Cclass methods
DAll of the above
Correct Answer All of the above
50
Which of these keywords can be used to prevent Method overriding?
Astatic
Bconstant
Cprotected
Dfinal
Correct Answer final
51
Which of these keywords is used to define interfaces in Java?
Aintf
BIntf
Cinterface
DInterface
Correct Answer interface
52
Which of these packages contains the exception Stack Overflow in Java?
Ajava.io
Bjava.system
Cjava.lang
Djava.util
Correct Answer java.lang
53
An interface with no fields or methods is known as a ______.
ARunnable Interface
BMarker Interface
CAbstract Interface
DCharSequence Interface
Correct Answer Marker Interface
54
Which keyword is used for accessing the features of a package?
Apackage
Bimport
Cextends
Dexport
Correct Answer import
55
Correct statement about a class and interface is/are
AAn interface can extend multiple interfaces
BA class can implement multiple interfaces.
CJava support multiple inheritance using interfaces.
DAll of the above.
Correct Answer All of the above.
56
Which of the following is the correct way of importing an entire package ā€˜pkg’?
Aimport pkg.
BImport pkg.
Cimport pkg.*
DImport pkg.*
Correct Answer import pkg.*
57
Which of the following package stores all the standard java classes?
Alang
Bjava
Cutil
Djava.packages
Correct Answer java
58
Which of these access specifiers can be used for an interface?
APublic
BProtected
Cprivate
DAll of the mentioned
Correct Answer Public
59
What kind of methods does an interface contain by default?
Aabstract
Bstatic
Cfinal
Dprivate
Correct Answer abstract
60
A Java static method can not be ___.
Aprivate or protected
Bfinal
Cabstract
DAll the above
Correct Answer All the above
61
Package in Java is a mechanism to encapsulate a ______________.
AClasses
BSub Packages
CInterfaces
DAll of the above
Correct Answer All of the above
62
Packages that are inside another package are the _________
Apackages
Bnested packages
Cutil subpackages
Dsubpackages
Correct Answer subpackages
63
Which one is correct declaration for implementing two interfaces?
Aclass C implements A, B
Bclass C implements A, implements B
Cclass C implements A extends B
Dclass C implements A.B
Correct Answer class C implements A, B
64
………… Environment variable identifies the location of Java compiler?
ACLASSPATH
BPATH
CJAVAPATH
DCOMPILERPATH
Correct Answer PATH
65
PATH environment variable can be set using ______ .
ACommand line
BControl panel
CBoth A and B
DJava compiler
Correct Answer Both A and B
66
How to display value of PATH environment variable at command line?
APATH
BSet PATH
CShow PATH
DDisplay PATH
Correct Answer Set PATH
67
PATH environment variable identifies the location of ______
AJava compiler
BJava interpreter
CJava tools
DAll of the above
Correct Answer All of the above
← Back to All MCQs