To crack a SDET interview , you are required to know one programming language thoroughly. In this post I will go through some common questions asked in SDET interview with respect to JAVA.

1.What is the difference between Abstract and Interface in Java?

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.
In its most common form, an interface is a group of related methods with empty bodies.

Other common differences are:

ParameterAbstract ClassInterface
Default Method ImplementationIt can have default method implementationInterfaces provide pure abstraction & can not have implementation at all
VariablesIt may contain non-final variables.Variables declared in an interface are by default final
Keyword UsedAn abstract class can be extended using the keyword “extendsThe interface should be implemented using keyword ïmplements
Access ModifiersCan  have public, protected, private and default modifierInterface methods are by default public. you can not use any other access modifier with it
Speed of ImplementationIt is faster than the interfaceAn Interface is somewhat slower & require extra indirection
Normal ClassIt can extend only one abstract classCan implement multiple interfaces
ConstructorsAn abstract class can have constructorsAn interface can not have constructors
Multiple InheritanceAn abstract class can extend another class and can implement multiple Java interfacesThe interface can extend another Java interface only

2.What is the difference between Method overloading and Method Overriding?

Following are the key differences between method overloading and overriding in Java.

Method OverloadingMethod Overriding
It is used to increase the readability of the programProvides a specific implementation of the method already in the parent class
It is performed within the same classIt involves multiple classes
Parameters must be different in case of overloadingParameters must be same in case of overriding
Is an example of compile-time polymorphismIt is an example of runtime polymorphism
Return type can be different but you must change the parameters as well.Return type must be same in overriding
Static methods can be overloadedOverriding does not involve static methods.

3. What is different methods in SET and LIST in Java?

Set – MethodsList – Methods
add() – It is to add objects to a collection.void add(int index, Object obj) – It adds the object ‘obj’ at the specified ‘index‘ of the invoking list and it makes sure that no element is overwritten by shifting the previous elements.
clear() – It is to remove objects from a collection.boolean addAll(int index, Collection c) – It adds the entire collection ‘c’ to the invoking list and at the ‘index’ specified. It also ensures that no elements are overwritten. We can also check the correctness of its operation by examining the return value. It returns ‘true’ if the change is successful otherwise, it returns a value ‘false’.
contains() – It is to check whether the Set contains a certain object in it. It returns a value ‘true’ if the object is present in the Set.Object get(int index) – It returns the element or object at the specified ‘index’.
isEmpty() – It is to determine whether the collection helps in as no elements in it. It returns a value ‘true’ if there is no lastIndexOf(Object obj) – It works similar to the reverse of the indexOf() Method. It returns the last occurrence of the specified Object ‘obj’ and a value ‘1’ is returned if there of no such object in the list. Therefore, it can also be used as contains() Method of the Set Interface.
remove() – It is to remove an element from a collection by specifying it as a parameter to the method.ListIterator listIterator() – It returns an iterator to the starting index of the List.
size() – It is to count the number of objects or elements that a collection has.ListIterator listIterator(int index) – It helps in iterating through the invoking List starting at the specified ‘index’.
NAObject remove(int index) – It deletes the object at the specified ‘index’ and returns the deleted element as result. It also decrements the resultant list indices to reflect the deletion.
NAObject set(int index, Object obj) – It is to assign the Object ‘obj’ to the invoking list at the specified ‘index’.
NAList subList(int start, int end) – It is to include the objects from the index ‘start’ to the index ‘end’ in the list that has invoked the Method.

4. What is the difference between String buffer and String Builder?

StorageString PoolHeapHeap
Thread SafeNot used in a threaded environmentUsed in a multi-threaded environmentUsed in a single-threaded environment
PerformanceSlowSlower than StringBuilder but faster than StringFaster than StringBuffer
SyntaxString var =“QATechTools”;
String var=new String(“ QATechTools”);
StringBuffer var = new StringBuffer(“QATechTools”);StringBuilder var = new StringBuilder(“QATechTools”);

5. What is the difference between HashTable and HashMap in java?

SynchronizationNon-synchronized meaning that it is not thread-safe and cannot be shared between many threads without a proper synchronization code.Synchronized and can be shared with many threads
Null keysAllows only one null key and multiple null valuesDoes not allow null key or its value
Legacy SystemThis is a part of Java CollectionsHashtable is a legacy class was not part of the initial Java Collections
IteratorIterator is fail-fast and it throws a concurrentModificationException if any other thread tries to modify the mapThe enumerator is not fail-fast
Inheriting classInherits AbstractMap classInherits Dictionary class

6. What is the difference between Array and ArrayList?

Must include System namespace to use array.Must include System.Collections namespace to use ArraList.
Array Declaration & Initialization:
int[] arr = new int[5]
int[] arr = new int[5]{1, 2, 3, 4, 5};
int[] arr = {1, 2, 3, 4, 5};
ArrayList Declaration & Initialization:
ArrayList arList = new ArrayList();
Array stores a fixed number of elements. The size of an Array must be specified at the time of initialization.ArrayList grows automatically and you don’t need to specify the size.
Array is strongly typed. This means that an array can store only specific type of items\elements.ArrayList can store any type of items\elements.
No need to cast elements of an array while retrieving because it is strongly typed and stores a specific type of items only.The items of ArrayList need to be cast to an appropriate data type while retrieving. So, boxing and unboxing happens.
Performs faster than ArrayList because it is strongly typed.Performs slows because of boxing and unboxing.
Use static helper class Array to perform different tasks on the array.ArrayList itself includes various utility methods for various tasks.

7. What is the difference between Static and Final ?

ApplicableStatic keyword is applicable to nested static class, variables, methods and block.Final keyword is applicable to class, methods and variables.
InitializationIt is not compulsory to initialize the static variable at the time of its declaration.It is compulsory to initialize the final variable at the time of its declaration.
ModificationThe static variable can be reinitialized.The final variable can not be reinitialized.
MethodsStatic methods can only access the static members of the class, and can only be called by other static methods.Final methods can not be inherited.
ClassStatic class’s object can not be created, and it only contains static members only.A final class can not be inherited by any class.
BlockStatic block is used to initialize the static variables.Final keyword supports no such block.

8. What is the difference between Extends and Implements?

ImplementationA class can inherit another class, or an interface can inherit other interfaces using a keyword extendsA class can implement an interface using keyword implements
MethodThe subclass that extends a superclass may or may not override all the methods in a superclassThe class implementing an interface has to implement all the methods of that interface.
ClassA class can extend only one superclass.A class can implement any number of an interface at the same time
InterfaceAn interface can extend any number of interfacesAn interface can never implement any other interface