zulooplate.blogg.se

Java interview questions for testers
Java interview questions for testers




java interview questions for testers

Declare a static variable object of the class.

JAVA INTERVIEW QUESTIONS FOR TESTERS DRIVER

Singleton patterns are used in logging, caches, thread pools, configuration settings, device driver objects. println: The println is a method of java.io.PrintStream.Ī singleton is a class that is instantiated exactly once in the Java Virtual Machine.

java interview questions for testers

  • out: The out is a static member of the System class, and is an instance of j ava.io.PrintStream.
  • System: System is a class in the java.lang package.
  • If a constructor uses a super keyword, it must use it in the first line otherwise, there will be a compile-time error. public and abstract Q.60: How super keyword used with constructors?Ĭonstructors use super keyword to invoke the super class’s constructor. Only 2 modifiers are used with interface methods i.e. Q.59: Which modifiers are allowed for methods in an Interface? Interface contains only abstract methods(Java 8 provide default and static methods)Īn abstract class can have static, final or static final variable with any access specifier.Īn interface can only have public static final variableĪbstract classes can extend other class and implement interfaces.Īs an interface can not provide implementation, it can only extend other interfaceĪ subclass can extend only one abstract class and implement multiple interfaces. It can have abstract methods as well as concrete methods. Q.58: What is the difference between abstract class and interface? abstract classĪn abstract class provides partial abstraction Marker interfaces give instructions to JVM that classes implementing them will have special behavior and must be handled with care. It is used to provide some essential information to the JVM.įor example, Cloneable interface is used to mark object cloning and a Serializable interface is used to mark serialization and deserialization of an object. Q.57: What is a marker or tagged interface?Īn interface which has no members is known as a marker or tagged interface. For example Serializable, Cloneable, Remote etc. Multiple inheritances not supported in Java it is achieved through the interface. We can use interfaces in Java as a way to achieve polymorphism. Interface fields are public, static and final by default, and methods are public. The methods must have the exact same signature as declared in the interface. In Java, Interface contains only abstract methods, the class which implements the interface they will provide a definition for abstract methods.Ī class that implements an interface must implement all the methods declared in the interface. The interface in Java is a mechanism to achieve 100 %abstraction. That is the reason why objects of an abstract class are not allowed. So if Java allows you to create an object of this class then if someone calls the abstract method using that object then what would happen as there would be no actual implementation of the method to invoke. So these classes are incomplete, they have abstract methods that have nobody.

    java interview questions for testers

    Q.55: Why can’t we create the object of an abstract class?Īn abstract class is like a template, so you have to extend it and require subclasses to provide implementations for the abstract methods. Abstract class provide 0 to 100% abstraction.

    java interview questions for testers

    An abstract class can have data member, abstract method, method body, and constructor. If we inherit an abstract class, then we must provide implementations to all the abstract methods in it. It can have abstract methods(only method declaration without body) as well as concrete methods (regular methods with a body).Ībstract classes can not be instantiated, and require subclasses to provide implementations for the abstract methods. A class declared using “ abstract” keyword is called an abstract class.






    Java interview questions for testers