SlideShare a Scribd company logo
1 of 22
Top 20 Basic Java Interview
Questions for SDET
By DevLabs Alliance
Visit us at: www.devlabsalliance.com
Email: training@devlabsalliance.com
Contact: +91 9717514555
Java Interview Questions for SDET
1. What are the various access specifiers for Java classes?
There are 4 types of access specifiers in java:
• Public: Public class, public methods, or public variables can be accessible from
anywhere.
• Protected: Protected methods or fields can be accessed from the same class, or
subclass or from the class within the same package.
• Private: Private methods or fields can be accessed only from the same class to which
they belong.
• Default: Default methods or Default fields or Default class can be accessible only from
the same class or from the same package.
Java Interview Questions for SDET
2. Explain OOPS principles in Java.
The OOPS principles in Java are as follows:
• Abstraction: Abstraction is used to hide internal details and showing only the
functionality. In Java, we use abstract class and interface to achieve abstraction.
• Encapsulation: Encapsulation means to bind or wrap code and data together into a
single unit. A Java class is the example of Encapsulation.
• Polymorphism: Polymorphism means that one task is performed in different ways.
There are 2 types of Polymorphism: Run-time Polymorphism and Compile-Type
polymorphism.
• Inheritance: Inheritance means acquiring all the properties and behavior of an object.
It provides code re-usability.
Java Interview Questions for SDET
3. What is the difference between an Inner class and a sub-class?
An inner class is defined as a class which is nested within another class. An inner class can
access all methods and variables that are defined in the outer class.
Sub-class is defined as a class which is inherited from some another class which is called as
super class. A sub class can access only public and protected method and fields of its super
class.
Java Interview Questions for SDET
4. Can we overload main() method?
Yes, we can overload main() method like other methods.
But when we run the program, the program doesn’t execute the overloaded main method,
so we need to call the overloaded main method from the actual main method only.
Java Interview Questions for SDET
5. What is Final keyword in Java?
In Java, Final keyword can be used with variable, method and class.
If a variable is declared using Final keyword, then its value can be assigned only once and
after assignment it can’t be changed.
If a method is declared using Final keyword, then this method cannot be overridden by the
subclasses.
If a class is declared using Final keyword, then this class cannot be inherited.
Java Interview Questions for SDET
6. What is the difference between an Abstract Class and Interface?
Abstract Class Interface
It can have abstract and non-abstract methods It can have abstract methods only
Abstract keyword is used to declare abstract class Interface keyword is used to declare interface.
It can extend another Java class and implement
multiple Java interfaces.
It can extend another Java interface only
It can have class members like private, protected,
etc.
Members of Interface are public by default
It can have final, non-final, static and non-static
variables
It has only static and final variables.
It can provide the implementation of interface It can’t provide the implementation of abstract
class
Java Interview Questions for SDET
7. What is the difference between Local variables and Instance variables?
Local Variables: Local Variables are defined within a block or method or constructor.
These variables are created when the block is entered and destroyed after exiting from the
block. We can access these variables only within the block where they are declared.
We cannot use any access specifier with local variables.
Instance Variables: Instance variables are declared in a class outside any method, block or
constructor.
These variables are created when an object of the class is created and destroyed when the
object is destroyed. We can access these variables only by creating objects.
We can use access specifiers for instance variables. If no access specifier is specified then
the default access specifier is used.
Java Interview Questions for SDET
8. Can we declare the main method of our class as private?
Main method must always be public static in order to run any application correctly in Java.
If main method is declared as private, then it will not give any compilation error but the
program will not get executed and will give run-time error.
Java Interview Questions for SDET
9. What do you mean by Constructor and what is the need of
Constructor?
Constructor is defined as a member function in a class which has the same name as of class.
It is automatically called at the run-time whenever an object class is created.
It don’t have any return type.
Need of Constructor:
There might be a situation where exposing the class variable to the main program is not
secured. At that time the class variables can be declared as private because the private
variables are not accessible from the other class.
In such a situation, if constructors are defined, then the main method need not to access
the class variables directly.
Java Interview Questions for SDET
10. How many types of constructors are used in Java?
There are 2 types of constructors in Java:
• Default Constructor: In Java, Default constructor is the one which does not accept any
input. It is used to initialize the instance variable with the default values and is majorly
used for object creation. A default constructor is invoked implicitly by the compiler if no
constructor is defined by the user.
• Parameterized Constructor: In Java, Parameterized constructor is the one which is
capable of initializing the instance variables with the given values. In other words, those
constructors that accept the arguments are called parameterized constructors.
Java Interview Questions for SDET
11. What is the difference between this() and super() in Java?
this() and super() both are used to call the constructor.
this() super()
It represents the current instance of a class. It represents the current instance of parent class.
It is used to call the default constructor of the
same class.
It is used to call the default constructor of the
parent class.
It is used for pointing the instance of a current
class.
It is used to point the instance of parent class.
It is used to access methods of the current class. It is used to access the methods of parent class.
Java Interview Questions for SDET
12. Is it necessary for a try block to be followed by a catch block in Java
for Exception handling?
Try block always needs to be followed by either catch block or finally block or both.
If any exception is thrown from try block, then it should either be caught in catch block or if
any specific tasks needs to be performed before abortion, then they are put in a finally
block.
Java Interview Questions for SDET
13. What is a Thread?
Thread is a piece of code which can be executed independently.
In Java all program has atleast one thread called as main thread that is created by JVM. The
main thread is used to invoke the main() method of program.
Threads are executed concurrently.
Java Interview Questions for SDET
14. What are the various ways to create a Thread?
The user can create their own threads by following 2 ways:
• By extending Thread class:
public class Test extends Thread{
public void test2(){
}
}
• By Implementing Runnable Interface:
public class Test implements Runnable{
public void test2(){
}
}
Java Interview Questions for SDET
15. Explain Thread life cycle in Java.
New: In this state, the thread has been created but start() method is not invoked yet.
Runnable: The thread is in runnable state after start() method is invoked, but before the
invocation of run() method.
Running: The thread is in running state after invocation of run() method.
Blocked: The thread is alive but it is not eligible to run.
Terminated: The thread is in terminated state when the run() method is completed.
New Runnable Running Terminated
Blocked
Wait/sleep
Start() Exit method
Java Interview Questions for SDET
16. What is Method Overloading?
Method Overloading is a feature that allows a class to have more than one method with
the same name and different parameters.
We can overload the method by either changing number of arguments or changing the
data type.
public class Test{
public static int add(int a, int b) {return a+b};
public static int add(int a, int b, int c) {return a+b+c};
}
public class TestOverloadingMethod{
public static void main(String[] args){
System.out.println(Test.add(10,11));
System.out.println(Test.add(10,11,12));
}
}
Java Interview Questions for SDET
17. What is Method Overriding?
Method Overriding is a feature that allows a sub-class(child class) to have the same method
(with same name and same parameters) as that in the super class(parent class).
Method Overriding is used for run time polymorphism.
public class Vehicle{
void run(){System.out.println("Vehicle is running");
}}
//Creating a child class
class Bike extends Vehicle{
public static void main(String args[]){
//creating an instance of child class
Bike obj = new Bike();
//calling the method with child class instance
obj.run();
}
}
Java Interview Questions for SDET
18. What is meant by Collections in Java?
Collection is a group of objects represented as a single unit. It is a framework that provides
an architecture to store the objects and manipulate a group of objects.
Collections are used to perform the following operations:
• Searching
• Sorting
• Manipulation
• Insertion
• Deletion
Java Interview Questions for SDET
19. What is meant by Exception?
Exception is a problem that occurs when the normal flow of program is disrupted and
therefore program or application terminates abnormally.
Exceptions are a subclass of java.lang.Exception
To maintain the normal flow of application we can handle the Exception through Exception
handling.
Exception handling is a process to handle run-time errors such as IOException,
SQLException, etc.
Java Interview Questions for SDET
20. What are the types of Exception?
There are two types of Exception:
• Checked Exceptions: Checked Exceptions are the exceptions that are checked at the
time of compilation by compiler. These type of exceptions should be handled by the
programmer.
Eg.: FileNotFoundException, SQLException,etc.
• Unchecked Exceptions: Unchecked Exceptions are the exceptions that are not checked
at the time of compilation but they occurs at the time of execution. They are also called
as Runtime Exceptions.
Eg.: ArithmeticException, NullPointerException.
Visit us at: www.devlabsalliance.com
Email: training@devlabsalliance.com
Contact: +91 9717514555

More Related Content

What's hot

Design pattern application
Design pattern applicationDesign pattern application
Design pattern applicationgayatri thakur
 
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.2007Arun Kumar
 
201 core java interview questions oo ps interview questions - javatpoint
201 core java interview questions   oo ps interview questions - javatpoint201 core java interview questions   oo ps interview questions - javatpoint
201 core java interview questions oo ps interview questions - javatpointravi tyagi
 
8 most expected java interview questions
8 most expected java interview questions8 most expected java interview questions
8 most expected java interview questionsPoonam Kherde
 
Journey's diary developing a framework using tdd
Journey's diary   developing a framework using tddJourney's diary   developing a framework using tdd
Journey's diary developing a framework using tddeduardomg23
 
Technical interview questions
Technical interview questionsTechnical interview questions
Technical interview questionsSoba Arjun
 
Java design pattern tutorial
Java design pattern tutorialJava design pattern tutorial
Java design pattern tutorialAshoka Vanjare
 
TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010Stefano Paluello
 
When develpment met test(shift left testing)
When develpment met test(shift left testing)When develpment met test(shift left testing)
When develpment met test(shift left testing)SangIn Choung
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy CodeAndrea Polci
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated TestingLee Englestone
 
Unit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile AppsUnit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile AppsMarcelo Busico
 
Java Concurrency Starter Kit
Java Concurrency Starter KitJava Concurrency Starter Kit
Java Concurrency Starter KitMark Papis
 
Advanced java interview questions
Advanced java interview questionsAdvanced java interview questions
Advanced java interview questionsrithustutorials
 

What's hot (20)

Java interview question
Java interview questionJava interview question
Java interview question
 
Design pattern application
Design pattern applicationDesign pattern application
Design pattern application
 
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
 
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAUTest Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
 
201 core java interview questions oo ps interview questions - javatpoint
201 core java interview questions   oo ps interview questions - javatpoint201 core java interview questions   oo ps interview questions - javatpoint
201 core java interview questions oo ps interview questions - javatpoint
 
8 most expected java interview questions
8 most expected java interview questions8 most expected java interview questions
8 most expected java interview questions
 
Journey's diary developing a framework using tdd
Journey's diary   developing a framework using tddJourney's diary   developing a framework using tdd
Journey's diary developing a framework using tdd
 
Java scjp-part1
Java scjp-part1Java scjp-part1
Java scjp-part1
 
Technical interview questions
Technical interview questionsTechnical interview questions
Technical interview questions
 
Java design pattern tutorial
Java design pattern tutorialJava design pattern tutorial
Java design pattern tutorial
 
TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010
 
When develpment met test(shift left testing)
When develpment met test(shift left testing)When develpment met test(shift left testing)
When develpment met test(shift left testing)
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
 
Unit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile AppsUnit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile Apps
 
Working Effectively with Legacy Code
Working Effectively with Legacy CodeWorking Effectively with Legacy Code
Working Effectively with Legacy Code
 
Reflection in Java
Reflection in JavaReflection in Java
Reflection in Java
 
Java Concurrency Starter Kit
Java Concurrency Starter KitJava Concurrency Starter Kit
Java Concurrency Starter Kit
 
Advanced java interview questions
Advanced java interview questionsAdvanced java interview questions
Advanced java interview questions
 

Similar to Top 20 basic java interview questions for SDET

Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobGaruda Trainings
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview QuestionsKuntal Bhowmick
 
this keyword in Java.pdf
this keyword in Java.pdfthis keyword in Java.pdf
this keyword in Java.pdfParvizMirzayev2
 
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 questionsGradeup
 
Questions of java
Questions of javaQuestions of java
Questions of javaWaseem Wasi
 
1669617800196.pdf
1669617800196.pdf1669617800196.pdf
1669617800196.pdfvenud11
 
OOP in Java Presentation.pptx
OOP in Java Presentation.pptxOOP in Java Presentation.pptx
OOP in Java Presentation.pptxmrxyz19
 
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfJAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfnofakeNews
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Fresherszynofustechnology
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core ParcticalGaurav Mehta
 
Top 10 Interview Questions For Java
Top 10 Interview Questions For JavaTop 10 Interview Questions For Java
Top 10 Interview Questions For JavaEME Technologies
 
this keyword in Java.pptx
this keyword in Java.pptxthis keyword in Java.pptx
this keyword in Java.pptxParvizMirzayev2
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questionsSynergisticMedia
 
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
 

Similar to Top 20 basic java interview questions for SDET (20)

Core java questions
Core java questionsCore java questions
Core java questions
 
1
11
1
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a job
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
 
this keyword in Java.pdf
this keyword in Java.pdfthis keyword in Java.pdf
this keyword in Java.pdf
 
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
 
Questions of java
Questions of javaQuestions of java
Questions of java
 
1669617800196.pdf
1669617800196.pdf1669617800196.pdf
1669617800196.pdf
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
PPT Lecture-1.4.pptx
PPT Lecture-1.4.pptxPPT Lecture-1.4.pptx
PPT Lecture-1.4.pptx
 
Viva file
Viva fileViva file
Viva file
 
OOP in Java Presentation.pptx
OOP in Java Presentation.pptxOOP in Java Presentation.pptx
OOP in Java Presentation.pptx
 
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfJAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Freshers
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
 
Top 10 Interview Questions For Java
Top 10 Interview Questions For JavaTop 10 Interview Questions For Java
Top 10 Interview Questions For Java
 
this keyword in Java.pptx
this keyword in Java.pptxthis keyword in Java.pptx
this keyword in Java.pptx
 
Suga java training_with_footer
Suga java training_with_footerSuga java training_with_footer
Suga java training_with_footer
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
 
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...
 

Recently uploaded

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Recently uploaded (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

Top 20 basic java interview questions for SDET

  • 1. Top 20 Basic Java Interview Questions for SDET By DevLabs Alliance Visit us at: www.devlabsalliance.com Email: training@devlabsalliance.com Contact: +91 9717514555
  • 2. Java Interview Questions for SDET 1. What are the various access specifiers for Java classes? There are 4 types of access specifiers in java: • Public: Public class, public methods, or public variables can be accessible from anywhere. • Protected: Protected methods or fields can be accessed from the same class, or subclass or from the class within the same package. • Private: Private methods or fields can be accessed only from the same class to which they belong. • Default: Default methods or Default fields or Default class can be accessible only from the same class or from the same package.
  • 3. Java Interview Questions for SDET 2. Explain OOPS principles in Java. The OOPS principles in Java are as follows: • Abstraction: Abstraction is used to hide internal details and showing only the functionality. In Java, we use abstract class and interface to achieve abstraction. • Encapsulation: Encapsulation means to bind or wrap code and data together into a single unit. A Java class is the example of Encapsulation. • Polymorphism: Polymorphism means that one task is performed in different ways. There are 2 types of Polymorphism: Run-time Polymorphism and Compile-Type polymorphism. • Inheritance: Inheritance means acquiring all the properties and behavior of an object. It provides code re-usability.
  • 4. Java Interview Questions for SDET 3. What is the difference between an Inner class and a sub-class? An inner class is defined as a class which is nested within another class. An inner class can access all methods and variables that are defined in the outer class. Sub-class is defined as a class which is inherited from some another class which is called as super class. A sub class can access only public and protected method and fields of its super class.
  • 5. Java Interview Questions for SDET 4. Can we overload main() method? Yes, we can overload main() method like other methods. But when we run the program, the program doesn’t execute the overloaded main method, so we need to call the overloaded main method from the actual main method only.
  • 6. Java Interview Questions for SDET 5. What is Final keyword in Java? In Java, Final keyword can be used with variable, method and class. If a variable is declared using Final keyword, then its value can be assigned only once and after assignment it can’t be changed. If a method is declared using Final keyword, then this method cannot be overridden by the subclasses. If a class is declared using Final keyword, then this class cannot be inherited.
  • 7. Java Interview Questions for SDET 6. What is the difference between an Abstract Class and Interface? Abstract Class Interface It can have abstract and non-abstract methods It can have abstract methods only Abstract keyword is used to declare abstract class Interface keyword is used to declare interface. It can extend another Java class and implement multiple Java interfaces. It can extend another Java interface only It can have class members like private, protected, etc. Members of Interface are public by default It can have final, non-final, static and non-static variables It has only static and final variables. It can provide the implementation of interface It can’t provide the implementation of abstract class
  • 8. Java Interview Questions for SDET 7. What is the difference between Local variables and Instance variables? Local Variables: Local Variables are defined within a block or method or constructor. These variables are created when the block is entered and destroyed after exiting from the block. We can access these variables only within the block where they are declared. We cannot use any access specifier with local variables. Instance Variables: Instance variables are declared in a class outside any method, block or constructor. These variables are created when an object of the class is created and destroyed when the object is destroyed. We can access these variables only by creating objects. We can use access specifiers for instance variables. If no access specifier is specified then the default access specifier is used.
  • 9. Java Interview Questions for SDET 8. Can we declare the main method of our class as private? Main method must always be public static in order to run any application correctly in Java. If main method is declared as private, then it will not give any compilation error but the program will not get executed and will give run-time error.
  • 10. Java Interview Questions for SDET 9. What do you mean by Constructor and what is the need of Constructor? Constructor is defined as a member function in a class which has the same name as of class. It is automatically called at the run-time whenever an object class is created. It don’t have any return type. Need of Constructor: There might be a situation where exposing the class variable to the main program is not secured. At that time the class variables can be declared as private because the private variables are not accessible from the other class. In such a situation, if constructors are defined, then the main method need not to access the class variables directly.
  • 11. Java Interview Questions for SDET 10. How many types of constructors are used in Java? There are 2 types of constructors in Java: • Default Constructor: In Java, Default constructor is the one which does not accept any input. It is used to initialize the instance variable with the default values and is majorly used for object creation. A default constructor is invoked implicitly by the compiler if no constructor is defined by the user. • Parameterized Constructor: In Java, Parameterized constructor is the one which is capable of initializing the instance variables with the given values. In other words, those constructors that accept the arguments are called parameterized constructors.
  • 12. Java Interview Questions for SDET 11. What is the difference between this() and super() in Java? this() and super() both are used to call the constructor. this() super() It represents the current instance of a class. It represents the current instance of parent class. It is used to call the default constructor of the same class. It is used to call the default constructor of the parent class. It is used for pointing the instance of a current class. It is used to point the instance of parent class. It is used to access methods of the current class. It is used to access the methods of parent class.
  • 13. Java Interview Questions for SDET 12. Is it necessary for a try block to be followed by a catch block in Java for Exception handling? Try block always needs to be followed by either catch block or finally block or both. If any exception is thrown from try block, then it should either be caught in catch block or if any specific tasks needs to be performed before abortion, then they are put in a finally block.
  • 14. Java Interview Questions for SDET 13. What is a Thread? Thread is a piece of code which can be executed independently. In Java all program has atleast one thread called as main thread that is created by JVM. The main thread is used to invoke the main() method of program. Threads are executed concurrently.
  • 15. Java Interview Questions for SDET 14. What are the various ways to create a Thread? The user can create their own threads by following 2 ways: • By extending Thread class: public class Test extends Thread{ public void test2(){ } } • By Implementing Runnable Interface: public class Test implements Runnable{ public void test2(){ } }
  • 16. Java Interview Questions for SDET 15. Explain Thread life cycle in Java. New: In this state, the thread has been created but start() method is not invoked yet. Runnable: The thread is in runnable state after start() method is invoked, but before the invocation of run() method. Running: The thread is in running state after invocation of run() method. Blocked: The thread is alive but it is not eligible to run. Terminated: The thread is in terminated state when the run() method is completed. New Runnable Running Terminated Blocked Wait/sleep Start() Exit method
  • 17. Java Interview Questions for SDET 16. What is Method Overloading? Method Overloading is a feature that allows a class to have more than one method with the same name and different parameters. We can overload the method by either changing number of arguments or changing the data type. public class Test{ public static int add(int a, int b) {return a+b}; public static int add(int a, int b, int c) {return a+b+c}; } public class TestOverloadingMethod{ public static void main(String[] args){ System.out.println(Test.add(10,11)); System.out.println(Test.add(10,11,12)); } }
  • 18. Java Interview Questions for SDET 17. What is Method Overriding? Method Overriding is a feature that allows a sub-class(child class) to have the same method (with same name and same parameters) as that in the super class(parent class). Method Overriding is used for run time polymorphism. public class Vehicle{ void run(){System.out.println("Vehicle is running"); }} //Creating a child class class Bike extends Vehicle{ public static void main(String args[]){ //creating an instance of child class Bike obj = new Bike(); //calling the method with child class instance obj.run(); } }
  • 19. Java Interview Questions for SDET 18. What is meant by Collections in Java? Collection is a group of objects represented as a single unit. It is a framework that provides an architecture to store the objects and manipulate a group of objects. Collections are used to perform the following operations: • Searching • Sorting • Manipulation • Insertion • Deletion
  • 20. Java Interview Questions for SDET 19. What is meant by Exception? Exception is a problem that occurs when the normal flow of program is disrupted and therefore program or application terminates abnormally. Exceptions are a subclass of java.lang.Exception To maintain the normal flow of application we can handle the Exception through Exception handling. Exception handling is a process to handle run-time errors such as IOException, SQLException, etc.
  • 21. Java Interview Questions for SDET 20. What are the types of Exception? There are two types of Exception: • Checked Exceptions: Checked Exceptions are the exceptions that are checked at the time of compilation by compiler. These type of exceptions should be handled by the programmer. Eg.: FileNotFoundException, SQLException,etc. • Unchecked Exceptions: Unchecked Exceptions are the exceptions that are not checked at the time of compilation but they occurs at the time of execution. They are also called as Runtime Exceptions. Eg.: ArithmeticException, NullPointerException.
  • 22. Visit us at: www.devlabsalliance.com Email: training@devlabsalliance.com Contact: +91 9717514555