201 Core Java Interview Questions - OOPs Interview Questions - Javatpoint
201 Core Java Interview Questions - OOPs Interview Questions - Javatpoint
Theanswersofthecorejavainterviewquestionsareshortandto
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 2 3 4 5 6 7 8
CoreJava:BasicsofJavaInterviewQuestions
JVM
JVMsareavailableformanyhardwareandsoftwareplatforms(so
JVMisplatformdependent).
JRE
JDK
http://www.javatpoint.com/corejavainterviewquestions 1/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
moredetails...
Manytypes:
1.Class(Method)Area
2.Heap
3.Stack
4.ProgramCounterRegister
5.NativeMethodStack
moredetails...
3)WhatisJITcompiler?
4)Whatisplatform?
The Java platform differs from most other platforms in the sense
that it's a softwarebased platform that runs on top of other
hardwarebasedplatforms.Ithastwocomponents:
1.RuntimeEnvironment
2.API(ApplicationProgrammingInterface)
http://www.javatpoint.com/corejavainterviewquestions 2/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
7)Whatisclassloader?
TheclassloaderisasubsystemofJVMthatisusedtoloadclasses
and interfaces.There are many types of classloaders e.g.
Bootstrap classloader, Extension classloader, System classloader,
Pluginclassloaderetc.
Yes, save your java file by .java only, compile it by javac .java
andrunbyjavayourclassnameLet'stakeasimpleexample:
1. //saveby.javaonly
2. classA{
3. publicstaticvoidmain(Stringargs[]){
4. System.out.println("Hellojava")
5. }
6. }
7. //compilebyjavac.java
8. //runbyjavaA
compileitbyjavac.java
runitbyjavaA
No.
http://www.javatpoint.com/corejavainterviewquestions 3/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
Itisempty.Butnotnull.
Programcompilesandrunsproperly.
Thelocalvariablesarenotinitializedtoanydefaultvalue,neither
primitivesnorobjectreferences.
CoreJavaOOPsConcepts:InitialOOPs
InterviewQuestions
TheobjectreferencesareallinitializedtonullinJava.
http://www.javatpoint.com/corejavainterviewquestions 4/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
CoreJavaOOPsConcepts:Constructor
InterviewQuestions
15)Whatisconstructor?
Constructorisjustlikeamethodthatisusedtoinitializethe
state of an object. It is invoked at the time of object
creation.
moredetails...
16)Whatisthepurposeofdefaultconstructor?
17)Doesconstructorreturnanyvalue?
Ans:yes, that is current instance (You cannot use return type yet
itreturnsavalue).moredetails...
18)Isconstructorinherited?
No,constructorisnotinherited.
19)Canyoumakeaconstructorfinal?
No,constructorcan'tbefinal.
CoreJavaOOPsConcepts:statickeyword
InterviewQuestions
20)Whatisstaticvariable?
http://www.javatpoint.com/corejavainterviewquestions 5/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
moredetails...
21)Whatisstaticmethod?
moredetails...
22)Whymainmethodisstatic?
becauseobjectisnotrequiredtocallstaticmethodifItwere non
staticmethod,jvmcreatsobjectfirstthencallmain()methodthat
will lead to the problem of extra memory allocation.more
details...
23)Whatisstaticblock?
Isusedtoinitializethestaticdatamember.
moredetails...
Ans)Yes,oneofthewayisstaticblock.moredetails...
http://www.javatpoint.com/corejavainterviewquestions 6/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
staticorclassmethod instancemethod
1)A method i.e. declared as static is A method i.e. not
knownasstaticmethod. declared as static is
known as instance
method.
CoreJavaOOPsConcepts:InheritanceInterview
Questions
27)Whatisthisinjava?
28)WhatisInheritance?
moredetails...
Objectclass.
30)Whymultipleinheritanceisnotsupportedin
java?
http://www.javatpoint.com/corejavainterviewquestions 7/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
31)Whatiscomposition?
Holdingthereferenceoftheotherclasswithinsomeotherclassis
knownascomposition.
33)WhyJavadoesnotsupportpointers?
Pointerisavariablethatreferstothememoryaddress.Theyare
notusedinjavabecausetheyareunsafe(unsecured)andcomplex
tounderstand.
34)Whatissuperinjava?
No.Becausesuper()orthis()mustbethefirststatement.
36)Whatisobjectcloning?
CoreJavaOOPsConcepts:MethodOverloading
InterviewQuestions
http://www.javatpoint.com/corejavainterviewquestions 8/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
37)Whatismethodoverloading?
38)Whymethodoverloadingisnotpossibleby
changingthereturntypeinjava?
Becauseofambiguity.moredetails...
39)Canweoverloadmain()method?
Yes,Youcanhavemanymain()methodsinaclassbyoverloading
themainmethod.
moredetails...
CoreJavaOOPsConcepts:MethodOverriding
InterviewQuestions
40)Whatismethodoverriding:
41)Canweoverridestaticmethod?
No,youcan'toverridethestaticmethodbecausetheyarethepart
ofclassnotobject.
42)Whywecannotoverridestaticmethod?
Itisbecausethestaticmethodisthepartofclassanditisbound
with class whereas instance method is bound with object and
static gets memory in class area and instance gets memory in
heap.
43)Canweoverridetheoverloadedmethod?
http://www.javatpoint.com/corejavainterviewquestions 9/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
Yes.
Method MethodOverriding
Overloading
1)Methodoverloading Method overriding provides the specific
increases the implementation of the method that is
readability of the alreadyprovidedbyitssuperclass.
program.
45)CanyouhavevirtualfunctionsinJava?
Yes,allfunctionsinJavaarevirtualbydefault.
46)Whatiscovariantreturntype?
CoreJavaOOPsConcepts:finalkeyword
InterviewQuestions
47)Whatisfinalvariable?
Ifyoumakeanyvariableasfinal,youcannotchangethevalueof
finalvariable(Itwillbeconstant).moredetails...
48)Whatisfinalmethod?
http://www.javatpoint.com/corejavainterviewquestions 10/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
Finalmethodscan'tbeoverriden.moredetails...
49)Whatisfinalclass?
Finalclasscan'tbeinherited.moredetails...
50)Whatisblankfinalvariable?
Afinalvariable,notinitalizedatthetimeofdeclaration,isknown
asblankfinalvariable.moredetails...
51)Canweintializeblankfinalvariable?
Yes,onlyinconstructorifitisnonstatic.Ifitisstaticblankfinal
variable, it can be initialized only in the static block.more
details...
52)Canyoudeclarethemainmethodasfinal?
Yes,suchas,publicstaticfinalvoidmain(String[]args){}.
next
1 2 3 4 5 6 7 8
http://www.javatpoint.com/corejavainterviewquestions 11/12
2/10/2017 201CoreJavaInterviewQuestions|OOPsinterviewquestionsjavatpoint
http://www.javatpoint.com/corejavainterviewquestions 12/12