[go: up one dir, main page]

0% found this document useful (0 votes)
18 views33 pages

Commonly Asked Java and Selenium Interview Questions

Uploaded by

sindhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views33 pages

Commonly Asked Java and Selenium Interview Questions

Uploaded by

sindhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Jenkins password - 5e42b6083e88483e9c0ba7c187bd2b0b

What is Bytecode? What is JDK, JVM, JRE?

Bytecode is the reason Java become platform independent as


soon as the program is compiled bytecode is generated- it is a machine code
in the form of .class file 0101 like wise

A bytecode in Java is the instruction set for Java Virtual Machine

JDK is a software development environment used for making applets and


Java applications. The full form of JDK is Java Development Kit.

JRE(Java Runtime Environment) is a piece of a software which is designed


to run other software. It contains the class libraries, loader class, and JVM

JVM is an engine that provides a runtime environment to drive the Java


Code or applications. It converts Java bytecode into machine language.
JVM is a part of Java Run Environment (JRE)

What is the role of ClassLoader in Java?

The Java Class Loader is a part of the Java Runtime Environment that dynamically
loads Java classes into the Java Virtual Machine.

Can you save a java file without name?

What are wrapper classes and why do we need? Difference


between int and Integer?

Wrapper classes provide a way to use primitive data types ( int, boolean,
etc..) as objects.

The objects are necessary if we wish to modify the arguments passed into the method
(because primitive types are passed by value). The classes in java. util package handles
only objects and hence wrapper classes help in this case also

Integer we can reverse number or rotate it left or right using reverse(), rotateLeft() and
rotateRight() respectively.

What is immutable classes? Name 5 immutable classes in Java?


How to make a class immutable?
Immutable class means that once an object is created, we cannot change its content. In
Java, all the wrapper classes (like Integer, Boolean, Byte, Short) and String class is
immutable.

 The class must be declared as final (So that child classes can’t be created)
 Data members in the class must be declared as final (So that we can’t change
the value of it after object creation)
 A parameterized constructor
 Getter method for all the variables in it
 No setters(To not have the option to change the value of the instance variable)

What are OOPS concepts? Explain them. What all OOPS concepts
have you used in your framework?

Encapsulation simply means binding object state(fields) and


behaviour(methods) together. If you are creating class, you are doing
encapsulation.

The whole idea behind encapsulation is to hide the implementation details


from users. If a data member is private it means it can only be accessed within
the same class. No outside class can access private data member (variable)
of other class.

Data abstraction is the process of hiding certain details and showing only
essential information to the user.

OBJECT ORIENTED PROGRAMMING (OOP) is a programming concept


that works on the principles of abstraction, encapsulation, inheritance, and
polymorphism

Encapsulation – Top menu

Inheritance – Extends from page class file

Interface – Itest listner

WebDriver driver = new FirefoxDriver();


driver.quit();
driver = new ChromeDriver();
WebDriver is an interface and all the methods which are declared in
Webdriver interface are implemented by respective driver class. But if we do
upcasting,we can run the scripts in any browser .i.e running the same
automation scripts in different browsers to achieve Runtime Polymorphism.
WebDriver driver = new FirefoxDriver();
Here, WebDriver is an interface, driver is a reference
variable, FirefoxDriver() is a Constructor, new is a keyword, and new
FirefoxDriver() is an Object.

What is Object class in Java? Explain role and importance of


toString, equal and hashcode method?

The Object class, in the java.lang package, sits at the top of the class hierarchy tree. Every class is a
descendant, direct or indirect, of the Object class

equals(Object otherObject) – As method name suggests, is used to simply


verify the equality of two objects.

In object class(Default implementation) two reference value represent the same


object or not.

Equals() method verify if both objects are equal wrt the data but the object class
returns false

hashcode() – Returns a unique integer value for the object in runtime. By default,
integer value is mostly derived from memory address of the object in heap

with the object memory address and the calculation in the Hashcode methode
hash code is returned its an it.

String class has own implementation of the hash code

native menthod are the method which are implemented in a different


languages(C,C++ like wise)

each object has a unique hash code

toString – is used to retrieve object information in string format

SYSO calls the toSting method in Object class which returns


classname+hashcode

To get a meaningful information need to override toString menthod internally

toString method is called by SYSO

What is method overloading and overriding? What is upcasting


and down casting?
Overloading occurs when two or more methods in one class
have the same method name but different parameters.

Overloading is known as compile-time polymorphism

Overriding occurs when two methods have the same method


name and parameters. One of the methods is in the parent class,
and the other is in the child class. Overriding allows a child class
to provide the specific implementation of a method that
is already present in its parent class.

Overriding is known as runtime polymorphism.

Upcasting: Upcasting is the typecasting of a child object to a parent object. Upcasting


can be done implicitly

1. Downcasting: Similarly, downcasting means the typecasting of a parent


object to a child object. Downcasting cannot be implicitly.
// Java program to demonstrate

// Upcasting Vs Downcasting

// Parent class

class Parent {

String name;

// A method which prints the

// signature of the parent class

void method()

System.out.println("Method from Parent");

}
// Child class

class Child extends Parent {

int id;

// Overriding the parent method

// to print the signature of the

// child class

@Override

void method()

System.out.println("Method from Child");

// Demo class to see the difference

// between upcasting and downcasting

public class GFG {

// Driver code

public static void main(String[] args)

// Upcasting
Parent p = new Child();

p.name = "GeeksforGeeks";

// This parameter is not accessible

// p.id = 1;

System.out.println(p.name);

p.method();

// Trying to Downcasting Implicitly

// Child c = new Parent(); - > compile time error

// Downcasting Explicitly

Child c = (Child)p;

c.id = 1;

System.out.println(c.name);

System.out.println(c.id);

c.method();

Can we overload private and final methods? Can we override


static methods?

1. private and final methods can be overloaded but they cannot be


overridden. It means a class can have more than one private/final
methods of same name but a child class cannot override the private/final
methods of their base class.
2. Static methods can be overloaded which means a class can have more
than one static method of same name. Static methods cannot be
overridden, even if you declare a same static method in child class it
has nothing to do with the same method of parent class.
3. We can declare static methods with same signature in subclass, but it is not
considered overriding as there won’t be any run-time polymorphism. Hence the
answer is ‘No’.
4. https://www.geeksforgeeks.org/can-we-overload-or-override-static-
methods-in-java/#:~:text=Can%20we%20Override%20static
%20methods,be%20any%20run%2Dtime%20polymorphism.

Can we override private and final methods?

No, We can not override private method in Java, just like we can not override static method in
Java. Like static methods, private method in Java is also bonded during compile time using static
binding by Type information and doesn't depends on what kind of object a particular reference
variable is holding. Since method overriding works on dynamic binding, its not possible to
override private method in Java. private methods are not even visible to Child class, they are
only visible and accessible in the class on which they are declared. private keyword provides
highest level of Encapsulation in Java. Though you can hide private method in Java by declaring
another private method with same name and different method signature.

Read more: https://www.java67.com/2012/08/can-we-override-private-method-in-


java.html#ixzz6ZAZTb6Ni

Should return type be same in method overloading and


overriding?

1. Return type of method does not matter in case of method overloading, it


can be same or different. However in case of method overriding the
overriding method can have more specific return type (refer this).
2. Static binding is being used for overloaded methods and dynamic
binding is being used for overridden/overriding methods.

return types can be different, but they can only restrict the type used in the super class
because of the Liskov Substitution Principle.

Association of method call to the method body is known as binding. There are
two types of binding: Static Binding that happens at compile time
and Dynamic Binding that happens at runtime.

https://beginnersbook.com/2013/04/java-static-dynamic-binding/
Can a overriding method throw new or broader checked
exception?

The overriding method must NOT throw checked exceptions that are new or broader
than those declared by the overridden method. For example, a method that declares a
FileNotFoundException cannot be overridden by a method that declares a
SQLException, Exception, or any other non-runtime exception unless it's a subclass of
FileNotFoundException.

Explain autoboxing in Java.

Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their
corresponding object wrapper classes. For example, converting an int to an Integer, a double to
a Double, and so on. If the conversion goes the other way, this is called unboxing.

Autoboxing - Character ch = 'a';

// 1. Unboxing through method invocation


int absVal = absoluteValue(i);
System.out.println("absolute value of " + i + " = " + absVal);

List<Double> ld = new ArrayList<>();


ld.add(3.1416); // Π is autoboxed through method invocation.

// 2. Unboxing through assignment


double pi = ld.get(0);
System.out.println("pi = " + pi);

What is abstract class and interface? Difference between abstract


class and interface? Can we have private methods in interfaces?
Can we have constructor in abstract classes? Can we make a
class abstract without any abstract methods?

Abstract class and interface both are used to achieve abstraction where we can declare
the abstract methods. Abstract class and interface both can't be instantiated.

Abstract class Interface

1) Abstract class can have abstract and Interface can have only abstract methods.
non-abstract methods. Since Java 8, it can have default and static
methods also.

2) Abstract class doesn't support Interface supports multiple inheritance.


multiple inheritance.

3) Abstract class can have final, non- Interface has only static and final variables.
final, static and non-static variables.
4) Abstract class can provide the Interface can't provide the implementation
implementation of interface. of abstract class.

5) The abstract keyword is used to The interface keyword is used to declare


declare abstract class. interface.

6) An abstract class can extend another An interface can extend another Java interface
Java class and implement multiple Java only.
interfaces.

7) An abstract class can be extended An interface can be implemented using


using keyword "extends". keyword "implements".

8) A Java abstract class can have class Members of a Java interface are public by
members like private, protected, etc. default.

9)Example: Example:
public abstract class Shape{ public interface Drawable{
public abstract void draw(); void draw();
} }

 Private interface method cannot be abstract and no private and abstract


modifiers together.
 Private method can be used only inside interface and other static and non-static
interface methods.
http://geeksforgeeks.org/private-methods-java-9-interfaces/
#:~:text=Rules%20For%20using%20Private%20Methods,and
%20non-static%20interface%20methods.

Yes! Abstract classes can have constructors!

Yes, when we define a class to be an Abstract Class it cannot be instantiated but that
does not mean an Abstract class cannot have a constructor. Each abstract class must
have a concrete subclass which will implement the abstract methods of that abstract
class.

es, you can declare abstract class without defining an abstract method in it. Once you
declare a class abstract it indicates that the class is incomplete and, you cannot instantiate
it

What is constructor and its uses? What is the difference between


super and this?
The purpose of constructor is to initialize the object of a class while the purpose of a
method is to perform a task by executing java code. Constructors cannot be abstract, final,
static and synchronised while methods can be. Constructors do not have return types while
methods do. Default,No arg,parameterized

Will this code compile?


1. public class Vehicle {
2. String model;
3. String color;
4.
5. public Vehicle(String model, String color) {
6. this.model=model;
7. this.color=color;
8.
9. }
10.
11. public static void main(String[] args) {
12. Vehicle v = new Vehicle(); - Constructor needs argument error
13. }
14. }

What will be the output of below code?

1. class Vehicle {
2.
3. public Vehicle() {
4. System.out.println("I am the super vehicle");
5. }
6. }
7.
8. class FourWheeler extends Vehicle {
9. public FourWheeler() {
10. System.out.println("I am a car or a truck or whatever 4 wheel has");
11. }
12. }
13.
14. class Car extends FourWheeler{
15. public Car() {
16. System.out.println("I am a car");
17. }
18. }
19.
20. public class Demo{
21. public static void main(String[] args) {
22. Car c = new Car();
23. }
24. }
25. I am the super vehicle
26. I am a car or a truck or whatever 4 wheel has
27. I am a car

What is the use of instanceof operator in java?


In Java, the instanceof keyword is a binary operator. It is used to check
whether an object is an instance of a particular class or not.
The operator also checks whether an object is an instance of a class that
implements an interface (will be discussed later in this tutorial).

result = objectName instanceof className;

https://www.programiz.com/java-programming/
instanceof#:~:text=In%20Java%2C%20the%20instanceof
%20keyword,discussed%20later%20in%20this%20tutorial).

What are the access modifiers in java? Explain visibility of public,


private, default and protractor?

There are two types of modifiers in Java: access modifiers and non-access modifiers.

The access modifiers in Java specifies the accessibility or scope of a field, method,
constructor, or class. We can change the access level of fields, constructors, methods,
and class by applying the access modifier on it

1. Private: The access level of a private modifier is only within the class. It cannot
be accessed from outside the class.
2. Default: The access level of a default modifier is only within the package. It
cannot be accessed from outside the package. If you do not specify any access
level, it will be the default.
3. Protected: The access level of a protected modifier is within the package and
outside the package through child class. If you do not make the child class, it
cannot be accessed from outside the package.
4. Public: The access level of a public modifier is everywhere. It can be accessed
from within the class, outside the class, within the package and outside the
packag

https://www.javatpoint.com/access-modifiers

What is the difference between Parent P = new Child() and Child


C = new Child() where Parent is a super class and Child is a base
class?
In the 1st case Parent class is used as a reference so the methods and variables defined
in parent class alone are accessible. In 2nd case Child class is used as a reference so that
all methods of parent class can be accessed as well as the extra methods of child class(if
present) can also be accessed.

What is the use of final keyword in a variable, method and class?

https://www.geeksforgeeks.org/final-keyword-java/#:~:text=First
%20of%20all%2C%20final%20is,contexts%20where%20final
%20is%20used.&text=When%20a%20variable%20is
%20declared,must%20initialize%20a%20final%20variable.

Difference between final, finally and finalize?

https://www.geeksforgeeks.org/g-fact-24-finalfinally-and-finalize-
in-java/?ref=rp

finalize – garbage collection

What is the difference between == and equal()?

== - object reference same or not and the address is same

.equals() – whether the content is same or not.

String name_1 = new String(“Sindhu”);


String name_2 = new String(“Sindhu”);

,equal = True

== = False (since the reference is different

String name 1 = “Sindhu”;

String name 2 = “Sindhu”;

.euqla – true and == also true since the object will created in
string constant pool

Singleton design pattern

Should have constructor as private so that no one can create an


object of this object externally

What will be the output of below code?

1. public class StringExample {


2.
3. public static void main(String[] args) {
4.
5. String s1 = "true";
6. String s2 = "true";
7.
8. //first sop
9. System.out.println(s1==s2);
10.
11. String s3= new String("true");
12.
13. //second sop
14. System.out.println(s1==s3);
15.
16. String s4= "True";
17.
18. //Third sop
19. System.out.println(s2==s4);
20.
21. }

true
false

true

22. }
What will be the output of below code?

1. public class StringExample {


2.
3. public static void main(String[] args) {
4.
5. String str = " hello ";
6. str.trim();
7. System.out.println(str);
8. }
9.
10. }

hello

How many methods of String class have you used? Name them
with example

https://www.seleniumeasy.com/java-tutorials/string-examples-
using-selenium-webdriver

What is the difference between String, Stringbuffer and


Stringbuilder?

https://www.geeksforgeeks.org/string-vs-stringbuilder-vs-
stringbuffer-in-java/

Where are String values stored in memory? Why String class is


immutable?

Strings are stored on the heap area in a separate memory location known
as String Constant pool. String constant pool: It is a separate block of memory where all
the String variables are held.

In java, string objects are immutable. Immutable simply means unmodifiable or


unchangeable.

Once string object is created its data or state can't be changed but a new string object is
created.

https://www.javatpoint.com/immutable-string#:~:text=In%20java
%2C%20string%20objects%20are,new%20string%20object%20is
%20created.&text=println(s)%3B%2F%2Fwill%20print%20Sachin
%20because%20strings%20are%20immutable%20objects

What is static block and instance block?


static blocks executes when class is loaded in java.

instance block executes only when instance of class is created, not


called when class is loaded in java.

javamadesoeasy.com/2015/06/differences-between-
instance.html#:~:text=static%20blocks%20executes%20when
%20class,be%20used%20in%20static%20blocks.

What is the default value of instance variable and local variable?

Instance variables have default values. For numbers, the default value is 0, for Booleans it is
false, and for object references it is null. Values can be assigned during the declaration or
within the constructor.

There is no default value for local variables, so local variables should be declared and an
initial value should be assigned before the first use.

tutorialspoint.com/java/java_variable_types.htm#:~:text=Local
%20variables%20are%20visible%20only,assigned%20before
%20the%20first%20use.

What is the use of static variable? Can we use static variables


inside non static methods? Can we use non static variables inside
static methods? How to invoke static methods?

In Java, static keyword is mainly used for memory management. It can be used
with variables, methods, blocks and nested classes. It is a keyword which is used to share
the same variable or method of a given class. Basically, static is used for a constant variable
or a method that is same for every instance of a class.

https://www.edureka.co/blog/static-keyword-in-java/#StaticBlock

When you declare a variable as static, then a single copy of the variable is created and
divided among all objects at the class level. Static variables are, essentially, global variables.
Basically, all the instances of the class share the same static variable. Static variables can
be created at class-level only.

non-static methods can access any static method and static variable also, without using
the object of the class. In static method, the method can only access
only static data members and static methods of another class or same class but cannot
access non-static methods and variables
https://www.geeksforgeeks.org/difference-between-static-and-non-static-method-in-java/
#:~:text=before%20method%20name.-,non%2Dstatic%20methods%20can%20access
%20any%20static%20method%20and%20static,the%20object%20of%20the
%20class.&text=members%20and%20methods-,In%20static%20method%2C%20the
%20method%20can%20only%20access%20only%20static,non%2Dstatic%20methods
%20and%20variables.

Static variables are class variable not instance or local variable . that is why we can use
static variable in non static method also.

https://study.com/academy/lesson/static-vs-non-static-methods-
in-java.html#:~:text=To%20create%20a%20static
%20method,design%20from%20the%20original%20dress.

A static method belongs to the class, and you do not have to create an instance of the
class to access the static method.

1. class Calc {

2. static int product(int x, int y) {

3. return x * y;

4. }

5. public static void main(String[] args) {

6. int ans = Calc.product(5, 3);

7. System.out.println(ans);

8. }

9. }

Is it a valid for loop?


1. Int i=0;
2. for(;i<10; i++){
3. System.out.println(i);
4. }
5. Valid

What is the difference between break and continue?


Break statement mainly used to terminate the enclosing loop such as while, do-while, for or
switch statement wherever break is declared. Continue statement mainly skip the rest of
loop wherever continue is declared and execute the next iteration.

What is the difference between while and do-while?

while loop check condition before iteration of the loop. On the other hand, the do-while loop
verifies the condition after the execution of the statements inside the loop

What will happen if we don’t have break statement inside


matching catch? Should default be the last statement in a switch
case block?

Switch case statements are used to execute only specific case statements based on the
switch expression. If we do not use break statement at the end of each case,
program will execute all consecutive case statements until it finds next break statement or
till the end of switch case block.

A 'switch' statement should have 'default' as the last label. Adding a 'default' label at the
end of every 'switch' statement makes the code clearer and guarantees that any
possible case where none of the labels matches the value of the control variable will be
handled.

Can your switch statement accept long, double or float data type?

The switch statement doesn't accept arguments of type long, float, double,boolean or
any object besides String

Compile time error will come

What is the hierarchy of throwable class? What are checked and


unchecked exceptions?

https://docstore.mik.ua/orelly/java/langref/
ch09_04.htm#:~:text=The%20possible%20exceptions%20in
%20a,immediate%20subclasses%3A%20Exception%20and
%20Error.

Checked: are the exceptions that are checked at compile time.

Unchecked are the exceptions that are not checked at compiled time

https://www.geeksforgeeks.org/checked-vs-unchecked-
exceptions-in-java/#:~:text=In%20Java%2C%20there%20are
%20two,are%20checked%20at%20compile%20time.&text=It
%20is%20up%20to%20the,else%20under%20throwable%20is
%20checked.

What is the difference between Error and Exception?

An Error "indicates serious problems that a reasonable application should not try to catch."
An Exception "indicates conditions that a reasonable application might want to catch

https://stackoverflow.com/questions/5813614/what-is-difference-
between-errors-and-exceptions#:~:text=An%20Error
%20%22indicates%20serious%20problems,should%20not%20try
%20to%20catch.%22&text=An%20Exception%20%22indicates
%20conditions%20that,their%20subclasses%20are
%20unchecked%20exceptions.&text=On%20the%20other
%20hand%20we%20have%20unchecked%20exceptions.

What is the difference between throw and throws?

Throw is a keyword which is used to throw an exception explicitly in the program inside a
function or inside a block of code. Throws is a keyword used in the method signature used
to declare an exception which might get thrown by the function while executing the code.

https://www.tutorialspoint.com/difference-between-throw-and-
throws-in-java#:~:text=Throw%20is%20a%20keyword
%20which,function%20while%20executing%20the%20code.

Is try block without finally and catch allowed?

Yes, we can have try without catch block by using finally block. You can
use try with finally. As you know finally block always executes even if you have exception
or return statement in try block except in case of System.

https://java2blog.com/can-we-have-try-without-catch-block-in-
java/#:~:text=Yes%2C%20we%20can%20have%20try,except
%20in%20case%20of%20System.
How to handle multi level exceptions?

A try block can be followed by one or more catch blocks. Each catch block must contain a
different exception handler. So, if you have to perform different tasks at the occurrence
of different exceptions, use java multi-catch block.

https://www.javatpoint.com/multiple-catch-block-in-java

https://www.geeksforgeeks.org/multicatch-in-java/

Will this code compile?

1. public class ExceptionExample {


2.
3. public static void main(String[] args) {
4.
5. try {
6. FileReader f = new FileReader(new File("D:\\myfile"));
7. }catch(IOException e) {
8.
9. }catch(FileNotFoundException e) {
10.
11. }
12. }
13.
14. }

Unreachable catch block for FileNotFoundException. It is already handled by the catch block for
IOException

What are the default values of array?

Everything in a Java program not explicitly set to something by the programmer, is


initialized to a zero value.

 For references (anything that holds an object) that is null.


 For int/short/byte/long that is a 0.
 For float/double that is a 0.0
 For booleans that is a false.
 For char that is the null character '\u0000' (whose decimal equivalent is
0).
When you create an array of something, all entries are also zeroed. So your array
contains five zeros right after it is created by new.

What is garbage collection?

https://stackify.com/what-is-java-garbage-collection/#:~:text=A
%20Definition%20of%20Java%20Garbage,programs%20perform
%20automatic%20memory%20management.&text=When
%20Java%20programs%20run%20on,will%20no%20longer%20be
%20needed.

How to run garbage collection? When will it run?

https://www.geeksforgeeks.org/garbage-collection-java/

1. Using System.gc() method : System class contain static method gc() for requesting
JVM to run Garbage Collector.
2. Using Runtime.getRuntime().gc() method : Runtime class allows the application to
interface with the JVM in which the application is running. Hence by using its gc()
method, we can request JVM to run Garbage Collector.

What are the ways to make objects eligible for garbage


collection?

https://www.geeksforgeeks.org/garbage-collection-java/

How many objects available for GC?

1. public class GC {
2.
3. public static void main(String[] args) {
4.
5. GC gc1= new GC();
6. GC gc2 = new GC();
7. GC gc3 = new GC();
8.
9. gc1 = null;
10. }
11.
12. }

Difference between System.gc() and Runtime.getRuntime().gc()?

There is no significant difference between System.gc() and Runtime.gc().

System.gc() internally calls Runtime.gc(). The only difference is


System.gc() is a class method whereas Runtime.gc() is an instance method.

Runtime.gc() is a native method whereas System.gc() is non - native


method which in turn calls the Runtime.gc().

How do you read contents of a file? How do you write in a file?

https://www.geeksforgeeks.org/different-ways-reading-text-file-
java/ - Read

https://www.geeksforgeeks.org/file-handling-java-using-filewriter-
filereader/ - Write

What is functional interface? Give example of functional


interfaces in Java?

A functional interface in Java is an interface that contains only a single


abstract (unimplemented) method. A functional interface can contain
default and static methods which do have an implementation, in addition to
the single unimplemented method.

http://tutorials.jenkov.com/java-functional-programming/
functional-interfaces.html#:~:text=A%20functional%20interface
%20in%20Java,to%20the%20single%20unimplemented
%20method.
https://www.geeksforgeeks.org/functional-interfaces-java/
#:~:text=They%20can%20have%20only%20one,the
%20examples%20of%20functional%20interfaces.

A functional interface is an interface that contains only one abstract method. They can have
only one functionality to exhibit. From Java 8 onwards, lambda expressions can be used to
represent the instance of a functional interface. A functional interface can have any number
of default methods. Runnable, ActionListener, Comparable are some of the examples of
functional interfaces.
Before Java 8, we had to create anonymous inner class objects or implement these
interfaces.

https://www.geeksforgeeks.org/functional-interfaces-java/
#:~:text=They%20can%20have%20only%20one,the
%20examples%20of%20functional%20interfaces.

What are marker interfaces in Java?

An empty interface in Java is known as a marker interface i.e. it does not contain any
methods or fields by implementing these interfaces a class will exhibit a special behavior
with respect to the interface implemented. java.

https://www.tutorialspoint.com/marker-interface-in-java-
programming#:~:text=An%20empty%20interface%20in
%20Java,java.

What is multithreading? Difference between process and thread?

Multithreading is a Java feature that allows concurrent execution of two or more parts of a
program for maximum utilization of CPU. Each part of such program is called a thread. So,
threads are light-weight processes within a process.

Process

Process means any program is in execution. Process control block controls the operation of
any process.

https://www.edureka.co/blog/java-thread/#:~:text=A%20thread
%20is%20actually%20a,a%20separate%20path%20of
%20execution.
https://www.geeksforgeeks.org/difference-between-process-and-
thread/

What is the difference between thread class and runnable


interface?

https://medium.com/@bharatkulratan/difference-between-
runnable-and-thread-in-java-aacced9dca44#:~:text=Runnable
%20is%20an%20interface%20which,t%20create%20a%20new
%20thread.

How to get today’s date using date class? How to add days in
today’s date?

https://howtodoinjava.com/java/date-time/add-days-to-date-
localdatetime/

How to get current month and year using calendar class?

import java.time.LocalDate;

import java.time.Month;

public class LocalDateJava8 {

public static void main(String args[]) {

//Getting the current date value

LocalDate currentdate = LocalDate.now();

System.out.println("Current date: "+currentdate);

//Getting the current day

int currentDay = currentdate.getDayOfMonth();

System.out.println("Current day: "+currentDay);


//Getting the current month

Month currentMonth = currentdate.getMonth();

System.out.println("Current month: "+currentMonth);

//getting the current year

int currentYear = currentdate.getYear();

System.out.println("Current month: "+currentYear);

 The getYear() method returns an integer representing the year filed in the
current LocalDate object.
 The getMonth() method returns an object of the java.timeMonth class
representing the month in the LocalDate object.
 The getDaYofMonth() method returns an integer representing the day in the
LocalDate object.
https://www.tutorialspoint.com/how-to-get-current-day-month-
and-year-in-java-8

What is stream in Java 8?

https://www.geeksforgeeks.org/stream-in-java/
#:~:text=Introduced%20in%20Java%208%2C%20the,to
%20produce%20the%20desired%20result.&text=Streams
%20don't%20change%20the,as%20per%20the%20pipelined
%20methods.

What is default and static methods in interface in Java 8?

https://www.geeksforgeeks.org/default-methods-java/
What is the difference between Collections and Collection?

The differences between the Collection and Collections are given below.

o The Collection is an interface whereas Collections is a class.


o The Collection interface provides the standard functionality of data structure to
List, Set, and Queue. However, Collections class is to sort and synchronize the
collection elements.
o The Collection interface provides the methods that can be used for data structure
whereas Collections class provides the static methods which can be used for
various operation on a collection.

https://www.javatpoint.com/java-collections-interview-
questions#:~:text=14)%20What%20is%20the%20difference
%20between%20Collection%20and%20Collections%3F&text=The
%20Collection%20is%20an%20interface,and%20synchronize
%20the%20collection%20elements.

What is the hierarchy of collection?

https://www.geeksforgeeks.org/collections-in-java-2/

What are the sub interfaces and sub classes of List, Set and Map
interface?

https://www.javatpoint.com/collections-in-java

What is the difference between ArrayList and LinkedList? Which


one is faster in insertion, deletion and random access memory?

https://www.javatpoint.com/difference-between-arraylist-and-
linkedlist

ArrayList is faster than LinkedList if I randomly access its elements. ... ArrayList has
direct references to every element in the list, so it can get the n-th element in constant
time. LinkedList has to traverse the list from the beginning to get to the n-th
element. LinkedList is faster than ArrayList for deletion
https://www.javatpoint.com/difference-between-arraylist-and-
linkedlist

What is the difference between singly linkedlist, doubly linkedlist


and circular linkedlist?

https://www.geeksforgeeks.org/difference-between-singly-linked-
list-and-doubly-linked-list/#:~:text=Introduction%20to%20Doubly
%20linked%20list,there%20in%20singly%20linked
%20list.&text=SLL%20has%20nodes%20with%20only%20a
%20data%20field%20and%20next%20link%20field.&text=The
%20DLL%20occupies%20more%20memory%20than%20SLL
%20as%20it%20has%203%20fields.

What main interfaces LinkedList implements?

https://www.geeksforgeeks.org/linked-list-in-java/

What is the difference between Stack and Queue?

https://www.geeksforgeeks.org/difference-between-stack-and-
queue-data-structures/#:~:text=Stack%20A%20stack%20is
%20a,the%20list%2C%20called%20the%20top.&text=The
%20insertion%20of%20an%20element%20in%20a%20queue
%20is%20called,is%20called%20a%20dequeue%20operation.

stack A stack is a linear data structure in which elements can be inserted and deleted only
from one side of the list, called the top. LIFO

A queue is a linear data structure in which elements can be inserted only from one side of
the list called rear, and the elements can be deleted only from the other side called
the front. FIFO

What is the difference between List and Set?

List is an ordered sequence of elements whereas Set is a distinct list of


elements which is unordered.
List <E>: An ordered collection (also known as a sequence). The user of
this interface has precise control over where in the list each element is
inserted.
Set<E>: A collection that contains no duplicate elements. More formally,
sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at
most one null element. As implied by its name, this interface models the
mathematical set abstraction.
What is HashMap?

HashMap is a part of Java’s collection since Java 1.2. It provides the basic implementation
of the Map interface of Java. It stores the data in (Key, Value) pairs.

https://www.geeksforgeeks.org/java-util-hashmap-in-java-with-
examples/

How to convert Array into Arraylist and Arraylist into Array?

https://www.geeksforgeeks.org/arraylist-array-conversion-java-
toarray-methods/

https://www.geeksforgeeks.org/conversion-of-array-to-arraylist-in-
java/?ref=rp

How to convert Set into List?

Java Set is a part of java.util package and extends java.util.Collection interface. It does not
allow the use of duplicate elements and at max can accommodate only one null element.
https://www.geeksforgeeks.org/program-to-convert-set-to-list-in-
java/

How to iterate HashSet and HashMap?

https://www.geeksforgeeks.org/traverse-through-a-hashset-in-
java/ - Hash set

https://www.geeksforgeeks.org/traverse-through-a-hashmap-in-
java/?ref=rp – Has Map

What is SortedSet and SortedMap?

https://www.geeksforgeeks.org/sortedset-java-examples/

https://www.geeksforgeeks.org/sortedmap-java-examples/

What is LinkedHashSet and LinkedHashMap?

https://www.geeksforgeeks.org/linkedhashset-in-java-with-
examples/

https://www.geeksforgeeks.org/linkedhashmap-class-java-
examples/

What is TreeSet and TreeMap?

https://www.geeksforgeeks.org/treeset-in-java-with-examples/
#:~:text=TreeSet%20is%20one%20of%20the,an%20explicit
%20comparator%20is%20provided.

https://www.geeksforgeeks.org/treemap-in-java/

What is the difference between HashTable and HashMap?

https://www.geeksforgeeks.org/differences-between-hashmap-
and-hashtable-in-java/

What are difference methods of Collections class have you used?

Hash Map - DP, Hash Set - handles


Can you iterate list forward and backward? Can you iterate
linkedlist forward and backward?

https://www.techiedelight.com/java-program-iterate-list-reverse-
order/

https://www.tutorialspoint.com/iterate-through-a-linkedlist-in-
reverse-direction-using-a-listiterator-in-java#:~:text=A
%20ListIterator%20can%20be%20used,reverse%20direction
%20and%20false%20otherwise.

What is the between comparable and comparator?

https://www.javatpoint.com/difference-between-comparable-and-
comparator

Why can we compare Strings without implementing compare() or


compareTo methods?

WAP to check if a given number in palindrome.

https://www.javatpoint.com/palindrome-program-in-java

WAP to count duplicates in a given string.

https://www.javatpoint.com/program-to-find-the-duplicate-
characters-in-a-string

WAP to reverse a string using inbuilt reverse method as well as


programmatically.

WAP to sort an array.

WAP to find min and max in array.

WAP to find sum of array.

WAP to find missing number in array.

WAP to find largest and second largest in array? Smallest and


second smallest in array?

Where have you used List, Set and Map in Selenium?

Example of Selenium methods using method overloading?


Can you name 10 interfaces in Selenium?

Have you ever designed framework? Please explain your


framework.

What is WebDriver and WebElement?

What is the super interface of WebDriver? What is the hierarchy of


WebDriver?

What are methods of WebDriver and WebElement?

What is the difference between findelement and findElements?

What are waits in selenium? Difference between implicit wait and


explicit wait?

What is the importance of / and // in xpath?

What is the importance of *, $ and ^ in Css selector?

What are the challenges you faced in automation? What are the
challenges you faced while working with IE browser?

Explain Page factory model.

How to read data from excel? Difference between HSSFWorkbook


and XSSFWorkbook?

How to read data from dynamic web table? How to fetch data
from last raw of dynamic web table?

How to handle multiple windows in Selenium? How to open a new


window? How do you switch from one window to another window?

How do you handle Alert? Can you write a method to check if alert
exists?

How do you handle frames in Selenium?

Can you write isElementPresent method?

What are the various example of locator strategies in Selenium?

What is the difference between Xpath and CSS locators?


How to select values from dropdown?

What is the difference between Action and Actions?

Actions is a class that is based on a builder design pattern. This is a user-facing


API for emulating complex user gestures.
Whereas Action is an Interface which represents a single user-interaction action. It
contains one of the most widely used methods perform().

How to do double click, right click, drag and drop?

What is robot class? Where do you use in Selenium?

What is the difference between quit and close?

Can you explain about some common exceptions in Selenium?

What is JavaScriptExecutor in Selenium?

JavaScriptExecutor is an interface that provides a mechanism to execute Javascript


through selenium driver. It provides “executescript” & “executeAsyncScript” methods, to run
JavaScript in the context of the currently selected frame or window

How do you do parallel execution? What is threadlocal?

What are the various ways of click and sendkeys in Selenium?

Various ways to click

signOnImage.sendKeys(Keys.RETURN);
2.1
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", signOnImage);

2.2
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementsByName('login')[0].click()");
3.1
Actions actions = new Actions(driver);
actions.click(signOnImage).perform();
3.2
Actions actions = new Actions(driver);
actions.moveToElement(signOnImage).click().perform();
3.3
Actions actions = new Actions(driver);
actions.clickAndHold(signOnImage).release().perform();
3.4
Actions actions = new Actions(driver);
actions.sendKeys(signOnImage, Keys.RETURN).perform();
Send Keys
WebElement inputField = driver.findElement(By.xpath(".//div/input[starts-with(@id,'4')
and @class=' input' and @type='text' and @placeholder='']"));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].value='text';", inputField);

Send Me Jobs Like This


APPLY
Job description
Introduction
As a Test Specialist at IBM, your analytical and technical skills will directly impact the quality of the software
we create. Come work in an agile environment where you will help each iteration reach the next level. Whether
the testing is manual, automated, or cognitive, you hold a key role in releasing the best deliverables to IBM’ers
and our clients.

Your Role and Responsibilities

 Attend daily Agile Scrum meetings.


 Participate and engage in Agile Sprint Planning and User Stories Backlog Grooming sessions, as Testing
stakeholder.
 Participate in Sprint demo and retrospective meetings to understand the new system functionalities being
delivered and provide feedback on testing.
 Manage and Assign User Stories to the team for testing, that are being delivered as part of the Sprint.
 Analyzing the User Story, Acceptance Criteria, Data Mappings Product Specification, Business
Requirements & Functional Design artifacts and prepare, Test Analysis & Test case documents for effective
testing of the system.
 Prepare Impact document and report to Project manager / Scrum master, if the user story being tested is
impacted or has dependency with other user story or functionalities.
 Perform Functional Test Execution, Test data preparation as per the Test case designed, to help out the team.
 Act as a single point of contact between CLient and the Team.

Required Technical and Professional Expertise

 8+ years experience in test strategy, planning, designing test cases on Data Management platform and data
migration.
 Should be hands-on on QuerySurge tool and Shell Scripting.
 Previously worked on data migration projects and ETL related testing. DataStage knowledge will be an
advantage
Preferred Technical and Professional Expertise

 Knowledge on Manual and functional testing,


 Knowledge on Agile methodology,
 Knowledge on defect life cycle

Capabilities {acceptInsecureCerts: false, browserName: chrome,


browserVersion: 85.0.4183.121, chrome: {chromedriverVersion: 85.0.4183.87
(cd6713ebf92fa..., userDataDir: C:\Users\LOKESW~1\AppData\L...},
goog:chromeOptions: {debuggerAddress: localhost:59149}, javascriptEnabled:
true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform:
WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true,
strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000,
script: 30000}, unhandledPromptBehavior: dismiss and notify,
webauthn:virtualAuthenticators: true}

Exception in thread "main"


org.openqa.selenium.ElementClickInterceptedException: element click
intercepted: Element <button class="btn blue" id="nextbtn" tabindex="2"
disabled="disabled">...</button> is not clickable at point (435, 374).
Other element would receive the click: <div class="blur_elem blur"></div>
(Session info: chrome=85.0.4183.121)

WebElement element = driver.findElement(By.xpath(“xpath”));


JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript(“arguments[0].click();”, element);
or

WebElement element = driver.findElement(By("element_path"));


Actions actions = new Actions(driver);
actions.moveToElement(element).click().perform();

<button class="btn blue" id="nextbtn" tabindex="2"><span>Next</span></button>

You might also like