201 Core Java Interview Questions - OOPs Interview Questions
201 Core Java Interview Questions - OOPs Interview Questions
ContentMenu
201 Core
Questions
Java
Interview
90%assuranceofinterviewquestions
Thereisthelistof201corejavainterviewquestions.Ifthereis
any core java interview question that have been asked to you,
kindly post it in the ask question section. We assure that you
will get here the 90% frequently asked interview questions and
answers.
The answers of the core java interview questions are short and
to the point. The core java interview questions are categorized
in Basics of java interview questions, OOPs interview questions,
String Handling interview questions, Multithreading interview
questions, collection interview questions, JDBC interview
questionsetc.
1
CoreJava:BasicsofJavaInterviewQuestions
JRE
JRE stands for Java Runtime Environment. It is the
implementationofJVM.
http://www.javatpoint.com/corejavainterviewquestions
1/13
7/18/2016
JDK
JDK is an acronym for Java Development Kit. It physically
exists.ItcontainsJRE+developmenttools.
moredetails...
3)WhatisJITcompiler?
JustInTime(JIT) compiler:It is used to improve the
performance. JIT compiles parts of the byte code that have
similar functionality at the same time, and hence reduces the
amountoftimeneededforcompilation.Herethetermcompiler
refers to a translator from the instruction set of a Java virtual
machine(JVM)totheinstructionsetofaspecificCPU.
4)Whatisplatform?
Aplatformisbasicallythehardwareorsoftwareenvironmentin
which a program runs. There are two types of platforms
softwarebased and hardwarebased. Java provides software
basedplatform.
http://www.javatpoint.com/corejavainterviewquestions
2/13
7/18/2016
7)Whatisclassloader?
The classloader is a subsystem of JVM that is used to load
classesandinterfaces.Therearemanytypesofclassloaderse.g.
Bootstrap
classloader,
Extension
classloader,
System
classloader,Pluginclassloaderetc.
//saveby.javaonly
classA{
publicstaticvoidmain(Stringargs[]){
System.out.println("Hellojava")
//compilebyjavac.java
//runbyjavaA
compileitbyjavac.java
runitbyjavaA
http://www.javatpoint.com/corejavainterviewquestions
3/13
7/18/2016
11)WhatifIwritestaticpublicvoidinsteadof
publicstaticvoid?
Programcompilesandrunsproperly.
CoreJavaOOPsConcepts:InitialOOPs
InterviewQuestions
There
is
given
more
than
50
OOPs
(ObjectOriented
Abstraction
interview
question,
Polymorphism
interviewquestionsetc.forbetterunderstanding.
13)Whatisdifferencebetweenobjectoriented
programming language and object based
programminglanguage?
http://www.javatpoint.com/corejavainterviewquestions
4/13
7/18/2016
except
Inheritance.
Examples
of
object
based
programminglanguagesareJavaScript,VBScriptetc.
CoreJavaOOPsConcepts:Constructor
InterviewQuestions
15)Whatisconstructor?
Constructor is just like a method that is used to initialize
the state of an object. It is invoked at the time of object
creation.
moredetails...
16)Whatisthepurposeofdefaultconstructor?
The default constructor provides the default values to the
objects. The java compiler creates a default constructor
onlyifthereisnoconstructorintheclass.moredetails...
17)Doesconstructorreturnanyvalue?
Ans:yes, that is current instance (You cannot use return type
yetitreturnsavalue).moredetails...
18)Isconstructorinherited?
No,constructorisnotinherited.
19)Canyoumakeaconstructorfinal?
http://www.javatpoint.com/corejavainterviewquestions
5/13
7/18/2016
No,constructorcan'tbefinal.
CoreJavaOOPsConcepts:statickeyword
InterviewQuestions
20)Whatisstaticvariable?
staticvariableisusedtoreferthecommonpropertyofall
objects (that is not unique for each object) e.g. company
nameofemployees,collegenameofstudentsetc.
staticvariablegetsmemoryonlyonceinclassareaatthe
timeofclassloading.
moredetails...
21)Whatisstaticmethod?
A static method belongs to the class rather than object of
aclass.
A static method can be invoked without the need for
creatinganinstanceofaclass.
static method can access static data member and can
changethevalueofit.
moredetails...
22)Whymainmethodisstatic?
because object is not required to call static method if It were
nonstatic method,jvm creats object first then call main()
method that will lead to the problem of extra memory
allocation.moredetails...
23)Whatisstaticblock?
Isusedtoinitializethestaticdatamember.
It is excuted before main method at the time of
classloading.
moredetails...
http://www.javatpoint.com/corejavainterviewquestions
6/13
7/18/2016
24)Canweexecuteaprogramwithoutmain()
method?
Ans)Yes,oneofthewayisstaticblock.moredetails...
25)Whatifthestaticmodifierisremovedfrom
thesignatureofthemainmethod?
Program
compiles.
But
at
runtime
throws
an
error
"NoSuchMethodError".
instancemethod
declared as static is
known as instance
method.
call
instance
methods.
3)Nonstatic
(instance)
example:
public
methods.
static
cube(intn){returnn*n*n}
CoreJavaOOPsConcepts:Inheritance
InterviewQuestions
27)Whatisthisinjava?
http://www.javatpoint.com/corejavainterviewquestions
7/13
7/18/2016
28)WhatisInheritance?
Inheritance is a mechanism in which one object acquires all the
properties and behaviour of another object of another class. It
representsISArelationship.ItisusedforCodeResusabilityand
MethodOverriding.
moredetails...
31)Whatiscomposition?
Holdingthereferenceoftheotherclasswithinsomeotherclass
isknownascomposition.
33)WhyJavadoesnotsupportpointers?
http://www.javatpoint.com/corejavainterviewquestions
8/13
7/18/2016
34)Whatissuperinjava?
It is a keyword that refers to the immediate parent class
object.moredetails...
36)Whatisobjectcloning?
Theobjectcloningisusedtocreatetheexactcopyofanobject.
moredetails...
CoreJavaOOPsConcepts:Method
OverloadingInterviewQuestions
37)Whatismethodoverloading?
If a class have multiple methods by same name but different
parameters,itisknownasMethodOverloading.Itincreasesthe
readabilityoftheprogram.moredetails...
38)Whymethodoverloadingisnotpossibleby
changingthereturntypeinjava?
Becauseofambiguity.moredetails...
39)Canweoverloadmain()method?
http://www.javatpoint.com/corejavainterviewquestions
9/13
7/18/2016
CoreJavaOOPsConcepts:MethodOverriding
InterviewQuestions
40)Whatismethodoverriding:
If a subclass provides a specific implementation of a method
that is already provided by its parent class, it is known as
Method Overriding. It is used for runtime polymorphism and to
provide the specific implementation of the method.more
details...
41)Canweoverridestaticmethod?
No, you can't override the static method because they are the
partofclassnotobject.
42)Whywecannotoverridestaticmethod?
It is because the static method is the part of class and it is
bound with class whereas instance method is bound with object
andstaticgetsmemoryinclassareaandinstancegetsmemory
inheap.
43)Canweoverridetheoverloadedmethod?
Yes.
MethodOverriding
http://www.javatpoint.com/corejavainterviewquestions
10/13
7/18/2016
1)
Method Methodoverridingprovidesthespecific
method Method
overriding
occurs
in
two
In
this
case, Inthiscase,parametermustbesame.
parameter must be
different.
45)CanyouhavevirtualfunctionsinJava?
Yes,allfunctionsinJavaarevirtualbydefault.
46)Whatiscovariantreturntype?
Now, since java5, it is possible to override any method by
changing the return type if the return type of the subclass
overriding method is subclass type. It is known as covariant
returntype.moredetails...
CoreJavaOOPsConcepts:finalkeyword
InterviewQuestions
47)Whatisfinalvariable?
If you make any variable as final, you cannot change the value
offinalvariable(Itwillbeconstant).moredetails...
48)Whatisfinalmethod?
Finalmethodscan'tbeoverriden.moredetails...
49)Whatisfinalclass?
http://www.javatpoint.com/corejavainterviewquestions
11/13
7/18/2016
Finalclasscan'tbeinherited.moredetails...
50)Whatisblankfinalvariable?
A final variable, not initalized at the time of declaration, is
knownasblankfinalvariable.moredetails...
51)Canweintializeblankfinalvariable?
Yes, only in constructor if it is nonstatic. If it is static blank
final variable, it can be initialized only in the static block.more
details...
52)Canyoudeclarethemainmethodasfinal?
Yes,suchas,publicstaticfinalvoidmain(String[]args){}.
next
1
Java
Basics
InterviewQuestions
Java
Java
Servlet
Spring
JDBC
Interview
Questions
JSP
Interview
Interview
Hibernate
Interview
Questions
Interview
Questions
Oracle
InterviewQuestions
Questions
Questions
PL/SQL
JavaString&Exception
Interview
Questions
Questions
Collection
InterviewQuestions
Multithreading
InterviewQuestions
SQL
Interview
Questions
Interview
http://www.javatpoint.com/corejavainterviewquestions
Android
Interview
12/13
7/18/2016
Questions
Questions
MySQL
Interview
Questions
http://www.javatpoint.com/corejavainterviewquestions
13/13