HomeAutomation

Java for Testers Interview Questions And Answers – Part 11

Java for Testers Interview Questions And Answers – Part 11

Java for Testers – Interview Questions and Answers Part-11

1) What is verbose?

Verbose is an option that can be used on the Java command to enable debug output for class loading.

2) What is thread count?

The Thread Count parameter specifies the maximum number of simultaneous requests the server can handle.
When the server has reached the limit or request threads, it defers processing new requests until the number of active requests drops below the maximum amount.

3) When a class implements two interfaces having a common method, which interface method does the class implement?

If a type implements two interfaces, and each interface define a method that has identical signature, then in effect there is only one method, and they are not distinguishable. There will be one implementation of both.

4) What is the flow of try, catch and finally blocks?

If a statement in try block raised an exception, then the rest of the try block doesn’t execute and control passes to the corresponding catch block. After executing the catch block, the control will be transferred to finally block(if present) and then the rest program will be executed.

5) What is finally in Java?

A finally block contains all the crucial statements that must be executed whether exception occurs or not.
The statements present in this block will always execute regardless of whether exception occurs in try block or not such as closing a connection, stream etc.

6) How many values will a method return in Java?

We can return only one value from a method in Java.

7) What is abstract in Java?

An abstract class, in the context of Java, is a superclass that cannot be instantiated and is used to state or define general characteristics. An object cannot be formed from a Java abstract class.
Trying to instantiate an abstract class only produces a compiler error.

8) Which design patterns have you used to develop frameworks?

We have used Singleton Design pattern to develop frameworks.

9) try block has exit method, catch block has exception and finally block is returning an int value. Can you explain the flow of execution?

It will exit the try block and skip the catch block. Then it will execute finally block to return int value.

10) Have you ever come across conflict in code. How do you resolve?

To resolve a merge conflict caused by competing line changes, you must choose which changes to incorporate from the different branches in a new commit.

11) Can a constructor be private?

Yes, we can declare a constructor as private. If we declare a constructor as private then we cannot create an object of that class.

12) Assert is an abstract or static method?

Assert is a static method type.

13) What is instance block at class level and method level?

Instance Initialization Blocks are used to initialize instance variables.

14) What is the difference between a Class and Interface?

– A class describes the attributes and behaviors of an object. An interface contains behaviors that a class implements.
– A class may contain abstract methods, concrete methods. An interface contains only abstract methods.

15) Can we have multiple catch blocks in try catch statements in Java?

Yes we can have multiple catch blocks in try catch statements in Java.

16) What is reflection in Java?

Reflection is an API which is used to examine or modify the behavior of methods, classes, interfaces at runtime.

17) What is nested Class?

A nested class is a member of its enclosing class. A nested class has access to the members, including private members, of the class in which it is nested.

18) What is mutable and immutable?

Mutable objects have fields that can be changed, immutable objects have no fields that can be changed after the object is created.
A class is immutable, as in, it is not mutable.

19) What are the types of Synchronization in Java?

Multi-threaded programs may often come to a situation where multiple threads try to access the same resources and finally produce erroneous and unforeseen results. So it needs to be made sure by some synchronization method that only one thread can access the resource at a given point of time.

20) What are the types of Exceptions in Java?

Java’s exceptions can be categorized into two types:
– Checked exceptions
– Unchecked exceptions

21) What is a class and object?

A class is a user defined blueprint or prototype from which objects are created.
It represents the set of properties or methods that are common to all objects of one type.
An object is an instance of a class.

22) How to call the function of a Class without creating an object?

Declare the function as static so that it can be called without creating an object of the class.

23) What is HashMap?

HashMap is a Map based collection class that is used for storing Key & value pairs.

24) How to synchronize Collection classes?

The synchronizedCollection() method of java. util. Collections class is used to return a
synchronized (thread-safe) collection backed by the specified collection.

25) Why main() is declared as static?

The main() method is static so that JVM can invoke it without instantiating the class.

Next Steps:

> More interview questions and answers on Java, continue to the next post (Click on Next Post link below)

> Check complete Java interview questions and answers here (Click here)

Please leave your questions/comments/feedback below.

Happy Learning 🙂

About Me > Bijan Patel

Connect to me on Linked In (Click here)

Visit me on my site (Click here)

On a mission to contribute to the Software Testing Community in all possible ways.

 

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *