SlideShare a Scribd company logo
INTERVIEW QUESTIONS
(Java Interview Questions)
© EME TECHNOLOGIES
Interview Questions
1. What is the most important feature of Java?
Java is a platform independent language.
2. What do you mean by platform independence?
Platform independence means that we can write and compile the java code in one
platform (eg Windows) and can execute the class in any other supported platform
eg (Linux,Solaris,etc).
3. What is a JVM?
JVM is Java Virtual Machine which is a run time environment for the compiled java
class files.
4. Are JVM’s platform independent?
JVM’s are not platform independent. JVM’s are platform specific run time
implementation provided by the vendor.
5. What is the difference between a JDK and a JVM?
JDK is Java Development Kit which is for development purpose and it includes
execution environment also. But JVM is purely a run time environment and hence
you will not be able to compile your source files using a JVM.
2
© EME TECHNOLOGIES
3
© EME TECHNOLOGIES
Interview Questions
6. What is a pointer and does Java support pointers?
Pointer is a reference handle to a memory location. Improper handling of pointers
leads to memory leaks and reliability issues hence Java doesn’t support the usage
of pointers.
7. What is the base class of all classes?
java.lang.Object
8. Does Java support multiple inheritance?
Java doesn’t support multiple inheritance.
9. Is Java a pure object oriented language?
Java uses primitive data types and hence is not a pure object oriented language.
10. Are arrays primitive data types?
In Java, Arrays are objects.
11. What is difference between Path and Classpath?
Path and Classpath are operating system level environment variales. Path is used
define where the system can find the executables(.exe) files and classpath is used
to specify the location .class files.
4
© EME TECHNOLOGIES
Interview Questions
12. What are instance variables?
Instance variables are those which are defined at the class level. Instance
variables need not be initialized before using them as they are automatically
initialized to their default values.
13. How to define a constant variable in Java?
The variable should be declared as static and final. So only one copy of the
variable exists for all instances of the class and the value can’t be changed also.
static final int PI = 2.14; is an example for constant.
14. Should a main() method be compulsorily declared in all java classes?
No not required. main() method should be defined only if the source class is a java
application.
15. What is the return type of the main() method?
Main() method doesn’t return anything hence declared void.
16. Why is the main() method declared static?
main() method is called by the JVM even before the instantiation of the class hence
it is declared as static.
5
© EME TECHNOLOGIES
Interview Questions
17. What is the arguement of main() method?
main() method accepts an array of String object as arguement.
18. Can a main() method be overloaded?
Yes. You can have any number of main() methods with different method signature
and implementation in the class.
19. Can a main() method be declared final?
Yes. Any inheriting class will not be able to have it’s own default main() method.
20. Does the order of public and static declaration matter in main() method?
No. It doesn’t matter but void should always come before main().
21. Can a source file contain more than one class declaration?
Yes a single source file can contain any number of Class declarations but only one
of the class can be declared aspublic.
22. What is a package?
Package is a collection of related classes and interfaces. package declaration
should be first statement in a java class.
23. Which package is imported by default?
java.lang package is imported by default even without a package declaration.
6
© EME TECHNOLOGIES
Interview Questions
24. Can a class be declared as protected?
A class can’t be declared as protected. only methods can be declared
as protected.
25. What is the access scope of a protected method?
A protected method can be accessed by the classes within the same package
or by the subclasses of the class in any package.
26. What is the purpose of declaring a variable as final?
A final variable’s value can’t be changed. final variables should be initialized
before using them.
27. What is the impact of declaring a method as final?
A method declared as final can’t be overridden. A sub-class can’t have the
same method signature with a different implementation.
28. I don’t want my class to be inherited by any other class. What should i
do?
You should declared your class as final. But you can’t define your class
as final, if it is an abstract class. A class declared as final can’t be extended by
any other class.
7
© EME TECHNOLOGIES
Interview Questions
29. Can we declare a static variable inside a method?
Static varaibles are class level variables and they can’t be declared inside a
method. If declared, the class will not compile.
30. What is use of a abstract variable?
Variables can’t be declared as abstract. only classes and methods can be
declared as abstract.
31. Class C implements Interface I containing method m1 and m2
declarations. Class C has provided implementation for method m2. Can i
create an object of Class C?
No not possible. Class C should provide implementation for all the methods in
the Interface I. Since Class Cdidn’t provide implementation for m1 method, it has
to be declared as abstract. Abstract classes can’t be instantiated.
32. What is a Marker Interface?
An Interface which doesn’t have any declaration inside but still enforces a
mechanism.
33. Which object oriented Concept is achieved by using overloading and
overriding?
Polymorphism. 8
© EME TECHNOLOGIES
Interview Questions
34. Why does Java not support operator overloading?
Operator overloading makes the code very difficult to read and maintain. To
maintain code simplicity, Java doesn’t support operator overloading.
35. Can we define private and protected modifiers for variables in interfaces?
No.
36. What is Externalizable?
Externalizable is an Interface that extends Serializable Interface. And sends data
into Streams in Compressed Format. It has two
methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in)
37. What modifiers are allowed for methods in an Interface?
Only public and abstract modifiers are allowed for methods in interfaces.
38. Can a Byte object be cast to a double value?
No, an object cannot be cast to a primitive value.
39. What is the difference between a static and a non-static inner class?
A non-static inner class may have object instances that are associated with
instances of the class’s outer class. A static inner class does not have any object
instances.
9
© EME TECHNOLOGIES
Interview Questions
40. When can an object reference be cast to an interface reference?
An object reference be cast to an interface reference when the object implements
the referenced interface.
41. Which class is extended by all other classes?
The Object class is extended by all other classes.
42. Which non-Unicode letter characters may be used as the first character of
an identifier?
The non-Unicode letter characters $ and _ may appear as the first character of an
identifier
43. What is a native method?
A native method is a method that is implemented in a language other than Java.
44. Can an anonymous class be declared as implementing an interface and
extending a class?
An anonymous class may implement an interface or extend a superclass, but may
not be declared to do both.
45. Does a class inherit the constructors of its superclass?
A class does not inherit constructors from any of its superclasses.
10
© EME TECHNOLOGIES
Interview Questions
46. What modifiers can be used with a local inner class?
A local inner class may be final or abstract.
47. When does the compiler supply a default constructor for a class?
The compiler supplies a default constructor for a class if no other constructors are
provided.
48. If a method is declared as protected, where may the method be accessed?
A protected method may only be accessed by classes or interfaces of the same
package or by subclasses of the class in which it is declared.
49. What are the legal operands of the instanceof operator?
The left operand is an object reference or null value and the right operand is a
class, interface, or array type.
50. To what value is a variable of the boolean type automatically initialized?
The default value of the boolean type is false.
11
© EME TECHNOLOGIES
12
© EME TECHNOLOGIES
Questions and Comments
13

More Related Content

What's hot

Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2
Sherihan Anver
 
Design pattern application
Design pattern applicationDesign pattern application
Design pattern application
gayatri thakur
 
Java design pattern tutorial
Java design pattern tutorialJava design pattern tutorial
Java design pattern tutorial
Ashoka Vanjare
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
Kuntal Bhowmick
 
8 most expected java interview questions
8 most expected java interview questions8 most expected java interview questions
8 most expected java interview questions
Poonam Kherde
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using ReflectionGanesh Samarthyam
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
talha ijaz
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
kavinilavuG
 
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Arun Kumar
 
Reflection in Java
Reflection in JavaReflection in Java
Reflection in Java
Nikhil Bhardwaj
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
talha ijaz
 
Professional-core-java-training
Professional-core-java-trainingProfessional-core-java-training
Professional-core-java-training
Vibrant Technologies & Computers
 
Java programming(unit 1)
Java programming(unit 1)Java programming(unit 1)
Java programming(unit 1)
SURBHI SAROHA
 
Java interview questions 1
Java interview questions 1Java interview questions 1
Java interview questions 1
Sherihan Anver
 
Java notes
Java notesJava notes
Java notes
Upasana Talukdar
 

What's hot (19)

Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2
 
Design pattern application
Design pattern applicationDesign pattern application
Design pattern application
 
Java scjp-part1
Java scjp-part1Java scjp-part1
Java scjp-part1
 
Java design pattern tutorial
Java design pattern tutorialJava design pattern tutorial
Java design pattern tutorial
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
 
8 most expected java interview questions
8 most expected java interview questions8 most expected java interview questions
8 most expected java interview questions
 
Java faq's
Java faq'sJava faq's
Java faq's
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
 
Reflection in Java
Reflection in JavaReflection in Java
Reflection in Java
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
Core java questions
Core java questionsCore java questions
Core java questions
 
Professional-core-java-training
Professional-core-java-trainingProfessional-core-java-training
Professional-core-java-training
 
Java programming(unit 1)
Java programming(unit 1)Java programming(unit 1)
Java programming(unit 1)
 
Java interview questions 1
Java interview questions 1Java interview questions 1
Java interview questions 1
 
Unit 4 Java
Unit 4 JavaUnit 4 Java
Unit 4 Java
 
Java notes
Java notesJava notes
Java notes
 

Similar to Top 10 Interview Questions For Java

Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
satish reddy
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
satish reddy
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
Gaurav Mehta
 
Top 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETTop 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDET
DevLabs Alliance
 
Dev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetDev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdet
devlabsalliance
 
Dev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdet
DevLabs Alliance
 
Java interview question
Java interview questionJava interview question
Java interview question
varatharajanrajeswar
 
1669617800196.pdf
1669617800196.pdf1669617800196.pdf
1669617800196.pdf
venud11
 
C# interview questions
C# interview questionsC# interview questions
C# interview questions
Chetan Chaudhari
 
java basic .pdf
java basic .pdfjava basic .pdf
java basic .pdf
Satish More
 
Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1
Mindsmapped Consulting
 
Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1
javatrainingonline
 
Core java interview questions1
Core java interview questions1Core java interview questions1
Core java interview questions1Lahari Reddy
 
Smart material - Unit 2 (1).pdf
Smart material - Unit 2 (1).pdfSmart material - Unit 2 (1).pdf
Smart material - Unit 2 (1).pdf
GayathriRHICETCSESTA
 
Smart material - Unit 2 (1).pdf
Smart material - Unit 2 (1).pdfSmart material - Unit 2 (1).pdf
Smart material - Unit 2 (1).pdf
GayathriRHICETCSESTA
 
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.
Questpond
 
Java
JavaJava
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
Shashwat Shriparv
 
Core java interview questions
Core java interview questionsCore java interview questions
Core java interview questions
Rohit Singh
 

Similar to Top 10 Interview Questions For Java (20)

Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
 
Top 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETTop 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDET
 
Dev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetDev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdet
 
Dev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdet
 
Java interview question
Java interview questionJava interview question
Java interview question
 
1669617800196.pdf
1669617800196.pdf1669617800196.pdf
1669617800196.pdf
 
Core java questions
Core java questionsCore java questions
Core java questions
 
C# interview questions
C# interview questionsC# interview questions
C# interview questions
 
java basic .pdf
java basic .pdfjava basic .pdf
java basic .pdf
 
Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1
 
Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1
 
Core java interview questions1
Core java interview questions1Core java interview questions1
Core java interview questions1
 
Smart material - Unit 2 (1).pdf
Smart material - Unit 2 (1).pdfSmart material - Unit 2 (1).pdf
Smart material - Unit 2 (1).pdf
 
Smart material - Unit 2 (1).pdf
Smart material - Unit 2 (1).pdfSmart material - Unit 2 (1).pdf
Smart material - Unit 2 (1).pdf
 
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.
 
Java
JavaJava
Java
 
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
 
Core java interview questions
Core java interview questionsCore java interview questions
Core java interview questions
 

Recently uploaded

Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 

Recently uploaded (20)

Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 

Top 10 Interview Questions For Java

  • 2. © EME TECHNOLOGIES Interview Questions 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform eg (Linux,Solaris,etc). 3. What is a JVM? JVM is Java Virtual Machine which is a run time environment for the compiled java class files. 4. Are JVM’s platform independent? JVM’s are not platform independent. JVM’s are platform specific run time implementation provided by the vendor. 5. What is the difference between a JDK and a JVM? JDK is Java Development Kit which is for development purpose and it includes execution environment also. But JVM is purely a run time environment and hence you will not be able to compile your source files using a JVM. 2
  • 4. © EME TECHNOLOGIES Interview Questions 6. What is a pointer and does Java support pointers? Pointer is a reference handle to a memory location. Improper handling of pointers leads to memory leaks and reliability issues hence Java doesn’t support the usage of pointers. 7. What is the base class of all classes? java.lang.Object 8. Does Java support multiple inheritance? Java doesn’t support multiple inheritance. 9. Is Java a pure object oriented language? Java uses primitive data types and hence is not a pure object oriented language. 10. Are arrays primitive data types? In Java, Arrays are objects. 11. What is difference between Path and Classpath? Path and Classpath are operating system level environment variales. Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .class files. 4
  • 5. © EME TECHNOLOGIES Interview Questions 12. What are instance variables? Instance variables are those which are defined at the class level. Instance variables need not be initialized before using them as they are automatically initialized to their default values. 13. How to define a constant variable in Java? The variable should be declared as static and final. So only one copy of the variable exists for all instances of the class and the value can’t be changed also. static final int PI = 2.14; is an example for constant. 14. Should a main() method be compulsorily declared in all java classes? No not required. main() method should be defined only if the source class is a java application. 15. What is the return type of the main() method? Main() method doesn’t return anything hence declared void. 16. Why is the main() method declared static? main() method is called by the JVM even before the instantiation of the class hence it is declared as static. 5
  • 6. © EME TECHNOLOGIES Interview Questions 17. What is the arguement of main() method? main() method accepts an array of String object as arguement. 18. Can a main() method be overloaded? Yes. You can have any number of main() methods with different method signature and implementation in the class. 19. Can a main() method be declared final? Yes. Any inheriting class will not be able to have it’s own default main() method. 20. Does the order of public and static declaration matter in main() method? No. It doesn’t matter but void should always come before main(). 21. Can a source file contain more than one class declaration? Yes a single source file can contain any number of Class declarations but only one of the class can be declared aspublic. 22. What is a package? Package is a collection of related classes and interfaces. package declaration should be first statement in a java class. 23. Which package is imported by default? java.lang package is imported by default even without a package declaration. 6
  • 7. © EME TECHNOLOGIES Interview Questions 24. Can a class be declared as protected? A class can’t be declared as protected. only methods can be declared as protected. 25. What is the access scope of a protected method? A protected method can be accessed by the classes within the same package or by the subclasses of the class in any package. 26. What is the purpose of declaring a variable as final? A final variable’s value can’t be changed. final variables should be initialized before using them. 27. What is the impact of declaring a method as final? A method declared as final can’t be overridden. A sub-class can’t have the same method signature with a different implementation. 28. I don’t want my class to be inherited by any other class. What should i do? You should declared your class as final. But you can’t define your class as final, if it is an abstract class. A class declared as final can’t be extended by any other class. 7
  • 8. © EME TECHNOLOGIES Interview Questions 29. Can we declare a static variable inside a method? Static varaibles are class level variables and they can’t be declared inside a method. If declared, the class will not compile. 30. What is use of a abstract variable? Variables can’t be declared as abstract. only classes and methods can be declared as abstract. 31. Class C implements Interface I containing method m1 and m2 declarations. Class C has provided implementation for method m2. Can i create an object of Class C? No not possible. Class C should provide implementation for all the methods in the Interface I. Since Class Cdidn’t provide implementation for m1 method, it has to be declared as abstract. Abstract classes can’t be instantiated. 32. What is a Marker Interface? An Interface which doesn’t have any declaration inside but still enforces a mechanism. 33. Which object oriented Concept is achieved by using overloading and overriding? Polymorphism. 8
  • 9. © EME TECHNOLOGIES Interview Questions 34. Why does Java not support operator overloading? Operator overloading makes the code very difficult to read and maintain. To maintain code simplicity, Java doesn’t support operator overloading. 35. Can we define private and protected modifiers for variables in interfaces? No. 36. What is Externalizable? Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in) 37. What modifiers are allowed for methods in an Interface? Only public and abstract modifiers are allowed for methods in interfaces. 38. Can a Byte object be cast to a double value? No, an object cannot be cast to a primitive value. 39. What is the difference between a static and a non-static inner class? A non-static inner class may have object instances that are associated with instances of the class’s outer class. A static inner class does not have any object instances. 9
  • 10. © EME TECHNOLOGIES Interview Questions 40. When can an object reference be cast to an interface reference? An object reference be cast to an interface reference when the object implements the referenced interface. 41. Which class is extended by all other classes? The Object class is extended by all other classes. 42. Which non-Unicode letter characters may be used as the first character of an identifier? The non-Unicode letter characters $ and _ may appear as the first character of an identifier 43. What is a native method? A native method is a method that is implemented in a language other than Java. 44. Can an anonymous class be declared as implementing an interface and extending a class? An anonymous class may implement an interface or extend a superclass, but may not be declared to do both. 45. Does a class inherit the constructors of its superclass? A class does not inherit constructors from any of its superclasses. 10
  • 11. © EME TECHNOLOGIES Interview Questions 46. What modifiers can be used with a local inner class? A local inner class may be final or abstract. 47. When does the compiler supply a default constructor for a class? The compiler supplies a default constructor for a class if no other constructors are provided. 48. If a method is declared as protected, where may the method be accessed? A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared. 49. What are the legal operands of the instanceof operator? The left operand is an object reference or null value and the right operand is a class, interface, or array type. 50. To what value is a variable of the boolean type automatically initialized? The default value of the boolean type is false. 11
  • 13. © EME TECHNOLOGIES Questions and Comments 13