[go: up one dir, main page]

0% found this document useful (0 votes)
67 views5 pages

Core Java: Basics of Java Interview Questions: 1) What Is Difference Between JDK, JRE and JVM? JVM

The document discusses key concepts in Core Java and OOPs including JDK, JRE, JVM, memory areas in JVM, Just-In-Time compiler, platform, differences between Java platform and other platforms, bytecode, classloader, valid Java file names, default values of local variables, differences between object-oriented and object-based programming languages, initial values of object references, constructors, static keyword, inheritance, and polymorphism. It provides explanations and examples for common interview questions related to these topics.

Uploaded by

veera6501
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views5 pages

Core Java: Basics of Java Interview Questions: 1) What Is Difference Between JDK, JRE and JVM? JVM

The document discusses key concepts in Core Java and OOPs including JDK, JRE, JVM, memory areas in JVM, Just-In-Time compiler, platform, differences between Java platform and other platforms, bytecode, classloader, valid Java file names, default values of local variables, differences between object-oriented and object-based programming languages, initial values of object references, constructors, static keyword, inheritance, and polymorphism. It provides explanations and examples for common interview questions related to these topics.

Uploaded by

veera6501
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Core Java: Basics of Java Interview Questions

1)What is difference between JDK,JRE and J !" J !


JVM is an acronym for Java Virtual Machine, it is an abstract machine which provides the runtime environment in which java bytecode can be executed. JVMs are available for many hardware and software platforms (so JVM is plateform dependent).

JRE
JR stands for Java Runtime nvironment. !t is the implementation of JVM and physically exists.

JDK
J"# is an acronym for Java "evelopment #it. !t physically exists. !t contains JR $ development tools. more details...

#)$ow %an& t&'es of %e%or& areas are a((ocated b& J !"


Many types% &. 'lass(Method) (rea ). *eap +. ,tac.. /ro0ram 'ounter Re0ister 1. 2ative Method ,tacmore details...

))What is JI* co%'i(er"


Just+In+*i%e,JI*) co%'i(er:!t is used to improve the performance. J!3 compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.*ere the term 4compiler5 refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific '/6.

-)What is '(atfor%"
( platform is basically the hardware or software environment in which a pro0ram runs. 3here are two types of platforms software7based and hardware7based. Java provides software7based platform.

.)What is the %ain difference between Java '(atfor% and other '(atfor%s"
3he Java platform differs from most other platforms in the sense that it8s a software7based platform that runs on top of other hardware7based platforms.!t has two components% &. Runtime nvironment ). (/!((pplication /ro0rammin0 !nterface)

/)What 0ives Java its 1write once and run an&where1 nature"
3he bytecode. Java is compiled to be a byte code which is the intermediate lan0ua0e between source code and machine code. 3his byte code is not platorm specific and hence can be fed to any platform.

2)What is c(ass(oader"
3he classloader is a subsystem of JVM that is used to load classes and interfaces.3here are many types of classloaders e.0. 9ootstrap classloader, xtension classloader, ,ystem classloader, /lu0in classloader etc.

3)Is E%'t& 45ava fi(e na%e a va(id source fi(e na%e"


:es, save your java file by .java only, compile it by 5avac 45ava and run by 5ava &ourc(assna%e ;et8s ta-e a simple example%
//save by .java only class A{ public static void main(String args[]){ System.out.println("Hello java") ! ! //compile by javac .java //run by java A

compile it by 5avac 45ava run it by 5ava 6

7)Is de(ete,ne8t,%ain,e8it or nu(( 9e&word in 5ava"


2o.

1:)If I do not 'rovide an& ar0u%ents on the co%%and (ine, then the ;trin0 arra& of !ain %ethod wi(( be e%'t& or nu(("
!t is empty. 9ut not null.

11)What if I write static 'ub(ic void instead of 'ub(ic static void"


/ro0ram compiles and runs properly.

1#)What is the defau(t va(ue of the (oca( variab(es"


3he local variables are not initiali<ed to any default value, neither primitives nor object references.

Core Java + <<=s Conce'ts: Initia( <<=s Interview Questions


3here is 0iven more than 1= >>/s (>bject7>riented /ro0rammin0 and ,ystem) interview ?uestions. 9ut they have been cate0ori<ed in many sections such as constructor interview ?uestions, static interview ?uestions, !nheritance !nterview ?uestions, (bstraction interview ?uestion, /olymorphism interview ?uestions etc. for better understandin0.

1))What is difference between ob5ect oriented 'ro0ra%%in0 (an0ua0e and ob5ect based 'ro0ra%%in0 (an0ua0e"
>bject based pro0rammin0 lan0ua0es follow all the features of >>/s except !nheritance. xamples of object based pro0rammin0 lan0ua0es are Java,cript, V9,cript etc.

1-)What wi(( be the initia( va(ue of an ob5ect reference which is defined as an instance variab(e"
3he object references are all initiali<ed to null in Java.

Core Java + <<=s Conce'ts: Constructor Interview Questions

1.)What is constructor"

'onstructor is just li-e a method that is used to initiali<e the state of an object. !t is invo-ed at the time of object creation.

more details...

1/)What is the 'ur'ose of defau(t constructor"

3he default constructor provides the default values to the objects. 3he java compiler creates a default constructor only if there is no constructor in the class.more details...

12)Does constructor return an& va(ue"


6ns:yes, that is current instance (:ou cannot use return type yet it returns a value).more details...

13)Is constructor inherited"


2o, constructor is not inherited.

17)Can &ou %a9e a constructor fina("


2o, constructor can8t be final.

Core Java + <<=s Conce'ts: static 9e&word Interview Questions


#:)What is static variab(e"

static variable is used to refer the common property of all objects (that is not uni?ue for each object) e.0. company name of employees,colle0e name of students etc. static variable 0ets memory only once in class area at the time of class loadin0.

more details...

#1)What is static %ethod"


( static method belon0s to the class rather than object of a class. ( static method can be invo-ed without the need for creatin0 an instance of a class. static method can access static data member and can chan0e the value of it.

more details...

##)wh& %ain %ethod is static"


because object is not re?uired to call static method if !t were non7static method,jvm creats object first then call main() method that will lead to the problem of extra memory allocation.more details...

#))What is static b(oc9"


!s used to initiali<e the static data member. !t is excuted before main method at the time of classloadin0.

more details...

#-)Can we e8ecute a 'ro0ra% without %ain,) %ethod"


(ns):es,one of the way is, by static bloc-.more details...

#.)What if the static %odifier is re%oved fro% the si0nature of the %ain %ethod"
/ro0ram compiles. 9ut at runtime throws an error @2o,uchMethod rror@.

#/)What is difference between static ,c(ass) %ethod and instance %ethod"


&)( method i.e. declared as static is -nown as static method. ))>bject is not re?uired to call static method. ( method i.e. not declared as static is -nown as instance method. >bject is re?uired to call instance methods.

+)2on7static (instance) members cannot be accessed in static and non7static variables both static context (static method, static bloc- and static nested can be accessed in instance class) directly. methods. .)Aor example% public static int cube(int n)B return nCnCnDE Aor example% public void ms0() B...E.

Core Java + <<=s Conce'ts: Inheritance Interview Questions

You might also like