Java for Selenium Interview Questions
Java for Selenium Interview Questions and Answers
1) Why we prefer Java for Selenium?
• Selenium written in Java, it doesn’t mean that Java only more compatible with selenium, we can use other supported languages also.
• Good support for Selenium with Java, You can get more help documents and implementations from Internet.
• Majority of Selenium Testers(nearly 77%) using Java, so knowledge sharing is very easy.
• Java is platform independent language, we can use it on any Operating environment.
2) How much Java is required for Selenium?
• For Test Automation using Selenium Core Java knowledge is sufficient, Advanced Java not required.
• Java Basics and Object Oriented Concepts are enough.
• Java Basics are Data Types, Variables, Modifiers, Operators, Flow Control statements, Functions, Comments etc…
• Java OOPS concepts are Abstraction, Polymorphism, Inheritance, and Encapsulation.
3) What is Java?
• Java Programming Language was developed by Sun Microsystems in 1995, Now it is subsidiary of Oracle corporation.
• Java is an Object Oriented programming Language, In Java, everything is an Object. Java can be easily extended since it is based on the Object model.
• Java is a Platform independent Language. It can be compiled and interpreted.
• Java is Simple, It is easy to learn and implement.
• java is Securable, using Java we can develop virus free and tamper free systems.
4) How to Set up Java Environment for Windows Operating Environment?
• Download Java (JDK) software and Install.
• Set Path Environment Variable to access Java from any directory.
• Download and extract Eclipse IDE to write and execute Java Programs.
For more information visit: http://www.gcreddy.com/2015/09/java-environment-setup-for-selenium.html
5) What are the Advantages of Java or usage of Java?
• Java is used to Develop Desktop Applications (Ex: Acrobat Reader)
• Java is used to Develop Web Applications.
• Java is used to Develop Enterprise Applications (ex: banking, Insurance Applications).
• Java is used to Develop Mobile applications.
• Java is used to Develop Embedded systems.
• Java is used to Develop Smart cards.
• Java is used to Develop Games Software etc…
6) What are the Java language Syntax Rules?
• Java is case sensitive language(deference is there in between upper and lower case letters)
• First letter of a Class Name should be in upper case.
• Method names should start with lower case letter
• Java Program file name should exactly match with class name.
• public static void main (String args)- Java program execution starts from main method, which is mandatory in every java program.
• Every statement should end with semi colon symbol.
7) What is the primary purpose of Comments?
To make the code readable.
8) What is Data Type?
Data type is a classification of the type of data that a variable or object can hold in Computer programming.
9) What are the 8 primitive data types in Java?
• Integer Data types
i) byte (8 bits)
ii) short (16 bits)
iii) int (32 bits)
iv) long (64 bits)
• Rational Data types (Numbers with decimal places)
v) float (32 bits)
vi) double (64 bits)
vii) char (16 bits)
9) What are Java Modifiers?
• Modifiers are keywords that we add to those definitions to change their meanings.
• Java has 2 types of modifiers, One is Access Modifiers another is Non-Access Modifiers.
• Access Modifiers are public, private, default and protected.
• Non-Access Modifiers are static, final, abstract etc…
10) What are the types of Variables in Java?
Java has 3 types of variables:
i) Instance variables
(A variable that is declared inside the class but outside the method.)
ii) Local variables
(A variable that is declared inside the Method.)
iii) Static / class variables
(A variable that is declared as static, It cannot be local.)
11) What are the categories of operators in Java?
Operators are used to perform mathematical, Comparison and Logical operations.
Important categories of Operators in Java:
i) Assignment Operators
ii) Arithmetic operators
iii) Relational operators
iv) Logical Operators
12) What are the Conditional statements in Java?
Types of Conditional statements in Java:
i) if statement
ii) switch statement
13) What are the Loop statements in Java?
Whenever we want execute a block of statements multiple times then we use Loop structures.
There are four types of Loop structures in Java.
i) for loop
ii) while loop
iii) do while loop
iv) Enhanced for loop
14) What is String?
• String is a sequence of characters written double quotes.
• String may have Alfa bytes, numbers and special characters.
15) Explain about Arrays in Java?
• Java Array is an Object that holds a fixed number of values of a single data type.
• The length of an Array is established when the Array is created.
• Array length is fixed, Java Array has Zero based index.
16) What are Java Methods?
• Method is a set of statements to perform an Operation.
• Methods also known as Procedures or Functions.
• In Structure programming we use Functions (Built in and User defined)
• In Object Oriented programming we use Methods (Built in and User defined)
17) What is Exception handling in Java?
• An exceptions is an event, which occurs during execution of a program.
• Exception handling is mechanism to handle exceptions.
18) What is Inheritance?
• It is a process of Inheriting (reusing) the class members (Variables and Methods) from one class to another class is called Inheritance.
• Non static (Object Level) class members only can be inherited.
• The class where the class members are getting inherited is called as Super class / parent class / Base class.
• The class to which the class members are getting inherited is called Sub class / Child class / Derived class.
• The inheritance between Super class and Sub class is achieved using “extends” keyword.
19) What is Polymorphism?
Polymorphism means, existence of Object behavior in many forms.
There are two types of Polymorphism in Java:
i) Compile Time Polymorphism / Static binding / Method overloading
ii) Run Time Polymorphism / Dynamic binding / Method overriding
20) What is Abstraction?
It is a process of hiding implementation details and showing only functionality to the user.
21) What is Java Interface?
• Interface is a Java type definition block which is 100% abstract.
• All the Interface methods are by default public and abstract.
• Static and final modifiers are not allowed for interface methods.
• In Interfaces variables have to initialize at the time of declaration.
22) What is Encapsulation?
It is a process of wrapping code and data into a single unit.
Encapsulation is the technique making the fields in a class private and providing access via public methods
• It provides us control over the data.
• By providing setter and getter methods, we can make a class read only or write only.
• If we don’t define setter method then read only.