SlideShare a Scribd company logo
25 Java Interview
Questions
What are the main features of Java?
 Object Oriented
 Simple
 Platform Independent
 Secured
 Robust
 Portable
 Multithreaded
 Distributed
What are the fundamental principles
of object oriented programming?
 Inheritance
 Abstraction
 Polymorphism
 Encapsulation
What do you mean by inheritance in
java?
 Inheritance is one of the Key principle of object oriented programming.
Through inheritance, one class can inherit the properties of another class.
The class from which properties are inherited is called super class and the
class to which properties are inherited is called sub class
What is constructor overloading? What
is the use of constructor overloading?
 A class can Have any number of constructors. These constructors will have
different list of arguments. It is called constructor overloading. Constructor
overloading provides different way to instantiate a class
What is polymorphism in java?
 Polymorphism refers to any entity whether it is a method or a constructor or
an operator which takes many forms or can be used for multiple tasks.
What is the method overloading in
java?
 If a class has more than one method with same name but with different list of
arguments, then it is called method overloading.
What is the method overriding?
 If a super class method is modified in the sub class then it is called method
overriding.
Does java supports multiple
inheritance?
 Java supports multiple inheritance but only through interfaces. That means a
class can implement more than one interfaces but can not extend more than
one class.
What is the difference between
constructor and method?
 Constructor is a special member of a class which is used to create the objects
to the class. It is special because it will have same name as class. It will have
no return type.
 Method is ordinary member of a class which is used to implement some
behavior of a class. It will have it’s own name and return type.
Can we overload the main() method?
 Yes, we can overload a main() method. A class can have any number of main()
methods. But, one of those must be in the form “public static void
main(String[] args)” in order to start the execution.
How the exceptions are handled in java? OR
Explain try, catch and finally blocks in java?
 Java has it’s own mechanism to handle the exceptions. In Java, exceptions
are handled using three blocks – try, catch and finally blocks.
 try block – The code to be monitored for exceptions will be kept in this block.
 catch block – If any exceptions occurred in try block, those exceptions will be
caught by this block.
 finally block – This block will be always executed whether exception is
raised or not and raised exceptions are caught or not.
What are PATH and CLASSPATH?
 PATH and CLASSPATH are two environment variables which need to be set in
order to compile and run the java programs.
What is multithreaded programming?
 Multithreaded programming is one of the key features of java which allows
multiple threads to execute their task simultaneously
What is the difference between error
and exception in java?
What are the differences between
static and non-static methods?
Static method is common to all instances of a class. Static methods are stored in
the class memory. Where as non-static methods are stored in the object memory.
Each instance of a class will have their own copy of non-static methods.
What are the differences between method
overloading and method overriding?
What are the different ways of
creating threads in java?
 There are two ways to create the threads in java
 a) By extending java.lang.Thread class.
 b) By implementing java.lang.Runnable interface.
What is static binding and dynamic binding
in java?
What is garbage collection in java?
Removing unwanted objects or abandoned objects from the memory is called
garbage collection. Garbage collection is done automatically in java. You need
not to remove the unwanted objects explicitly. Garbage collector thread does
this for you. click here to see how garbage collector thread works in java.
What is the difference between ArrayList
and Vector Class?
1) Thread Safety
This is the main difference between ArrayList and Vector class. ArrayList class is
not thread safety where as Vector class is thread safety. Vector class is a
synchronized class. Only one thread can enter into Vector object at any moment
of time during execution. Where as ArrayList class is not synchronized. Multiple
threads can access ArrayList object simultaneously. Below diagram clearly shows
that.
What is the difference between ArrayList
and Vector Class?
 Performance
ArrayList has better performance compared to Vector. It is because, Vector class
is synchronized. It makes the threads to wait for object lock to enter into vector
object. Where as ArrayList class is not synchronized. Threads need not to wait for
object lock to access ArrayList object. This makes ArrayList faster than the
Vector class.
What is cloning in java?
 Cloning is a process of creating an exact copy of an existing object in the
memory. Cloning may be shallow or deep. In java, clone() method is used to
create a clone of an object
What are differences between final, finally
and finalize in java?
 final is a keyword which is used to make a variable or a method or a class as
“unchangeable“. In simple terms,
 A variable which is declared as final, it’s value can not be changed once it is
initialized.
finally Block :
 finally is a block which is used for exception handling along with try and catch
blocks. finally block is always executed whether exception is raised or not and
raised exception is handled or not. Most of time, this block is used to close
the resources like database connection, I/O resources etc.
finalize() Method :
 finalize() method is a protected method of java.lang.Object class. It is
inherited to every class you create in java. This method is called by garbage
collector thread before an object is removed from the memory. finalize()
method is used to perform some clean up operations on an object before it is
removed from the memory.
What are checked and unchecked
exceptions in java?
Checked Exceptions :
 Checked exceptions are the exceptions which are known during compile time. These are the exceptions that are checked at compile time. They are also
called compile time exceptions.
 These exceptions must be handled either using try-catch blocks or using throws clause. If not handled properly, they will give compile time error.
 All sub classes of java.lang.Exception except sub classes of RunTimeException are checked exceptions.
 The following example throws checked exception. But it is not handled, so it gives compile time error.
 public class CheckedException
 {
 public static void main(String[] args)
 {
 Class.forName("AnyClassName");

 //Compile time error because
 //above statement throws ClassNotFoundException which is a checked exception
 //this statement must be enclosed within try-catch block or declare main method with throws clause
 }
 }
Unchecked Exceptions :
 Unchecked exceptions are the exceptions which are known at run time. They
can not be known at compile time because they occur only at run time. That’s
why they are also called Run Time Exceptions.
 All the sub classes of RunTimeException and all sub classes of Error class are
unchecked exceptions.
 If any statement in the program throws unchecked exceptions and you are not
handling them either using try-catch blocks or throws clause, then it does not
give compile time error. Compilation will be successful but program may fail
at run time. Therefore, to avoid premature termination of the program, you
have to handle them properly.

More Related Content

What's hot

The smartpath information systems java
The smartpath information systems javaThe smartpath information systems java
The smartpath information systems java
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O
Jyothishmathi Institute of Technology and Science Karimnagar
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview Qestions
Arun Vasanth
 
OCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class DesignOCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class Design
İbrahim Kürce
 
Questions of java
Questions of javaQuestions of java
Questions of java
Waseem Wasi
 
Core java by amit
Core java by amitCore java by amit
Core java by amit
Thakur Amit Tomer
 
Java classes and objects interview questions
Java classes and objects interview questionsJava classes and objects interview questions
Java classes and objects interview questionsDhivyashree Selvarajtnkpm
 
Java interface
Java interface Java interface
Java interface
HoneyChintal
 
OCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 ExceptionsOCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 Exceptions
İbrahim Kürce
 
Basic online java course - Brainsmartlabs
Basic online java course  - BrainsmartlabsBasic online java course  - Brainsmartlabs
Basic online java course - Brainsmartlabs
brainsmartlabsedu
 
Core java interview questions1
Core java interview questions1Core java interview questions1
Core java interview questions1Lahari Reddy
 
Advanced java interview questions
Advanced java interview questionsAdvanced java interview questions
Advanced java interview questions
rithustutorials
 
Java Concurrency Starter Kit
Java Concurrency Starter KitJava Concurrency Starter Kit
Java Concurrency Starter Kit
Mark Papis
 
Java Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRaoJava Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRao
JavabynataraJ
 
Chapter 9 java
Chapter 9 javaChapter 9 java
Chapter 9 java
Ahmad sohail Kakar
 
9781111530532 ppt ch10
9781111530532 ppt ch109781111530532 ppt ch10
9781111530532 ppt ch10Terry Yoast
 
Class test 1 sample questions
Class test 1 sample questionsClass test 1 sample questions
Class test 1 sample questions
Kuntal Bhowmick
 
Probable questions for semester exam
Probable questions for semester examProbable questions for semester exam
Probable questions for semester exam
Kuntal Bhowmick
 

What's hot (20)

The smartpath information systems java
The smartpath information systems javaThe smartpath information systems java
The smartpath information systems java
 
JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview Qestions
 
Java interview
Java interviewJava interview
Java interview
 
OCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class DesignOCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class Design
 
Questions of java
Questions of javaQuestions of java
Questions of java
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Core java by amit
Core java by amitCore java by amit
Core java by amit
 
Java classes and objects interview questions
Java classes and objects interview questionsJava classes and objects interview questions
Java classes and objects interview questions
 
Java interface
Java interface Java interface
Java interface
 
OCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 ExceptionsOCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 Exceptions
 
Basic online java course - Brainsmartlabs
Basic online java course  - BrainsmartlabsBasic online java course  - Brainsmartlabs
Basic online java course - Brainsmartlabs
 
Core java interview questions1
Core java interview questions1Core java interview questions1
Core java interview questions1
 
Advanced java interview questions
Advanced java interview questionsAdvanced java interview questions
Advanced java interview questions
 
Java Concurrency Starter Kit
Java Concurrency Starter KitJava Concurrency Starter Kit
Java Concurrency Starter Kit
 
Java Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRaoJava Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRao
 
Chapter 9 java
Chapter 9 javaChapter 9 java
Chapter 9 java
 
9781111530532 ppt ch10
9781111530532 ppt ch109781111530532 ppt ch10
9781111530532 ppt ch10
 
Class test 1 sample questions
Class test 1 sample questionsClass test 1 sample questions
Class test 1 sample questions
 
Probable questions for semester exam
Probable questions for semester examProbable questions for semester exam
Probable questions for semester exam
 

Similar to 25 java interview questions

1669617800196.pdf
1669617800196.pdf1669617800196.pdf
1669617800196.pdf
venud11
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Freshers
zynofustechnology
 
Top 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedTop 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedGaurav Maheshwari
 
Java Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedyearninginjava
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
Kuntal Bhowmick
 
this keyword in Java.pdf
this keyword in Java.pdfthis keyword in Java.pdf
this keyword in Java.pdf
ParvizMirzayev2
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Ayes Chinmay
 
Viva file
Viva fileViva file
Viva file
anupamasingh87
 
Java tips
Java tipsJava tips
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council Pune
Pankaj kshirsagar
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
G C Reddy Technologies
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
Gaurav Mehta
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questions
Gradeup
 
Chapter 8 java
Chapter 8 javaChapter 8 java
Chapter 8 java
Ahmad sohail Kakar
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
SynergisticMedia
 
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
OCA Java SE 8 Exam Chapter 4 Methods EncapsulationOCA Java SE 8 Exam Chapter 4 Methods Encapsulation
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
İbrahim Kürce
 
Java mcq
Java mcqJava mcq
Java mcq
avinash9821
 
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Sagar Verma
 
PPT Lecture-1.4.pptx
PPT Lecture-1.4.pptxPPT Lecture-1.4.pptx
PPT Lecture-1.4.pptx
HimanshuPandey957216
 
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
 

Similar to 25 java interview questions (20)

1669617800196.pdf
1669617800196.pdf1669617800196.pdf
1669617800196.pdf
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Freshers
 
Top 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedTop 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experienced
 
Java Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experienced
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
 
this keyword in Java.pdf
this keyword in Java.pdfthis keyword in Java.pdf
this keyword in Java.pdf
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
 
Viva file
Viva fileViva file
Viva file
 
Java tips
Java tipsJava tips
Java tips
 
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council Pune
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questions
 
Chapter 8 java
Chapter 8 javaChapter 8 java
Chapter 8 java
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
 
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
OCA Java SE 8 Exam Chapter 4 Methods EncapsulationOCA Java SE 8 Exam Chapter 4 Methods Encapsulation
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
 
Java mcq
Java mcqJava mcq
Java mcq
 
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3
 
PPT Lecture-1.4.pptx
PPT Lecture-1.4.pptxPPT Lecture-1.4.pptx
PPT Lecture-1.4.pptx
 
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
 

Recently uploaded

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 

Recently uploaded (20)

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 

25 java interview questions

  • 2. What are the main features of Java?  Object Oriented  Simple  Platform Independent  Secured  Robust  Portable  Multithreaded  Distributed
  • 3. What are the fundamental principles of object oriented programming?  Inheritance  Abstraction  Polymorphism  Encapsulation
  • 4. What do you mean by inheritance in java?  Inheritance is one of the Key principle of object oriented programming. Through inheritance, one class can inherit the properties of another class. The class from which properties are inherited is called super class and the class to which properties are inherited is called sub class
  • 5. What is constructor overloading? What is the use of constructor overloading?  A class can Have any number of constructors. These constructors will have different list of arguments. It is called constructor overloading. Constructor overloading provides different way to instantiate a class
  • 6. What is polymorphism in java?  Polymorphism refers to any entity whether it is a method or a constructor or an operator which takes many forms or can be used for multiple tasks.
  • 7. What is the method overloading in java?  If a class has more than one method with same name but with different list of arguments, then it is called method overloading.
  • 8. What is the method overriding?  If a super class method is modified in the sub class then it is called method overriding.
  • 9. Does java supports multiple inheritance?  Java supports multiple inheritance but only through interfaces. That means a class can implement more than one interfaces but can not extend more than one class.
  • 10. What is the difference between constructor and method?  Constructor is a special member of a class which is used to create the objects to the class. It is special because it will have same name as class. It will have no return type.  Method is ordinary member of a class which is used to implement some behavior of a class. It will have it’s own name and return type.
  • 11. Can we overload the main() method?  Yes, we can overload a main() method. A class can have any number of main() methods. But, one of those must be in the form “public static void main(String[] args)” in order to start the execution.
  • 12. How the exceptions are handled in java? OR Explain try, catch and finally blocks in java?  Java has it’s own mechanism to handle the exceptions. In Java, exceptions are handled using three blocks – try, catch and finally blocks.  try block – The code to be monitored for exceptions will be kept in this block.  catch block – If any exceptions occurred in try block, those exceptions will be caught by this block.  finally block – This block will be always executed whether exception is raised or not and raised exceptions are caught or not.
  • 13. What are PATH and CLASSPATH?  PATH and CLASSPATH are two environment variables which need to be set in order to compile and run the java programs.
  • 14. What is multithreaded programming?  Multithreaded programming is one of the key features of java which allows multiple threads to execute their task simultaneously
  • 15. What is the difference between error and exception in java?
  • 16. What are the differences between static and non-static methods? Static method is common to all instances of a class. Static methods are stored in the class memory. Where as non-static methods are stored in the object memory. Each instance of a class will have their own copy of non-static methods.
  • 17. What are the differences between method overloading and method overriding?
  • 18. What are the different ways of creating threads in java?  There are two ways to create the threads in java  a) By extending java.lang.Thread class.  b) By implementing java.lang.Runnable interface.
  • 19. What is static binding and dynamic binding in java?
  • 20. What is garbage collection in java? Removing unwanted objects or abandoned objects from the memory is called garbage collection. Garbage collection is done automatically in java. You need not to remove the unwanted objects explicitly. Garbage collector thread does this for you. click here to see how garbage collector thread works in java.
  • 21. What is the difference between ArrayList and Vector Class? 1) Thread Safety This is the main difference between ArrayList and Vector class. ArrayList class is not thread safety where as Vector class is thread safety. Vector class is a synchronized class. Only one thread can enter into Vector object at any moment of time during execution. Where as ArrayList class is not synchronized. Multiple threads can access ArrayList object simultaneously. Below diagram clearly shows that.
  • 22. What is the difference between ArrayList and Vector Class?  Performance ArrayList has better performance compared to Vector. It is because, Vector class is synchronized. It makes the threads to wait for object lock to enter into vector object. Where as ArrayList class is not synchronized. Threads need not to wait for object lock to access ArrayList object. This makes ArrayList faster than the Vector class.
  • 23. What is cloning in java?  Cloning is a process of creating an exact copy of an existing object in the memory. Cloning may be shallow or deep. In java, clone() method is used to create a clone of an object
  • 24. What are differences between final, finally and finalize in java?  final is a keyword which is used to make a variable or a method or a class as “unchangeable“. In simple terms,  A variable which is declared as final, it’s value can not be changed once it is initialized.
  • 25. finally Block :  finally is a block which is used for exception handling along with try and catch blocks. finally block is always executed whether exception is raised or not and raised exception is handled or not. Most of time, this block is used to close the resources like database connection, I/O resources etc.
  • 26. finalize() Method :  finalize() method is a protected method of java.lang.Object class. It is inherited to every class you create in java. This method is called by garbage collector thread before an object is removed from the memory. finalize() method is used to perform some clean up operations on an object before it is removed from the memory.
  • 27. What are checked and unchecked exceptions in java?
  • 28. Checked Exceptions :  Checked exceptions are the exceptions which are known during compile time. These are the exceptions that are checked at compile time. They are also called compile time exceptions.  These exceptions must be handled either using try-catch blocks or using throws clause. If not handled properly, they will give compile time error.  All sub classes of java.lang.Exception except sub classes of RunTimeException are checked exceptions.  The following example throws checked exception. But it is not handled, so it gives compile time error.  public class CheckedException  {  public static void main(String[] args)  {  Class.forName("AnyClassName");   //Compile time error because  //above statement throws ClassNotFoundException which is a checked exception  //this statement must be enclosed within try-catch block or declare main method with throws clause  }  }
  • 29. Unchecked Exceptions :  Unchecked exceptions are the exceptions which are known at run time. They can not be known at compile time because they occur only at run time. That’s why they are also called Run Time Exceptions.  All the sub classes of RunTimeException and all sub classes of Error class are unchecked exceptions.  If any statement in the program throws unchecked exceptions and you are not handling them either using try-catch blocks or throws clause, then it does not give compile time error. Compilation will be successful but program may fail at run time. Therefore, to avoid premature termination of the program, you have to handle them properly.