Core Java (For Automation Testers) – Interview Questions and Answers – Part 1

1. What is OOPS?

Object Oriented Programming System is the programming technique to write programs based on the real world objects. The states and behaviors of an object are represented as the member variables and methods. In OOPS programming programs are organized around objects and data rather than actions and logic.

2. What are the advantages of OOPS concepts?

Major advantages of OOPS programming are;
1. Simplicity: OOPS programming objects model real world objects, so the complexity is reduced and the program structure is clear.
2. Modularity: Each object forms a separate entity whose internal workings are decoupled from other parts of the system.
3. Modifiability: It is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods.
4.  Extensibility: Adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones.
5.  Maintainability: Objects can be maintained separately, making locating and fixing problems easier.
6.  Reusability: Objects can be reused in different programs1

3. What are the core concepts of OOPS?

OOPS core concepts are:
1. Abstraction
2. Encapsulation
3. Polymorphism
4. Inheritance
5. Composition
6. Association
7. Aggregation

4. Explain JDK,JRE and JVM in short.

JVM
JVM is an acronym for Java Virtual Machine, it is an abstract machine which provides the runtime environment in which java bytecode can be executed. It is a specification.
JVMs are available for many hardware and software platforms (so JVM is platform dependent).
JRE
JRE stands for Java Runtime Environment. It is the implementation of JVM.
JDK
JDK is an acronym for Java Development Kit. It physically exists. It contains JRE + development tools.

5. What is constructor?

Constructor is just like a method that is used to initialize the state of an object. It is invoked at the time of object creation.

6. What is the purpose of default constructor?

The default constructor provides the default values to the objects. The java compiler creates a default constructor only if there is no constructor in the class

7. Does constructor return any value?

Ans:yes, that is current instance (You cannot use return type yet it returns a value)

8. Is constructor inherited?

No, constructor is not inherited.

9. Can you make a constructor final?

No, constructor can’t be final.

10. What is static variable?
  •  static variable is used to refer the common property of all objects (that is not unique for each object) e.g. company name of employees,college name of students etc.
  •  static variable gets memory only once in class area at the time of class loading.
11. What is static block?
  • Is used to initialize the static data member.
  • It is executed before main method at the time of class loading.
12. Can we execute a program without main() method?

Yes, one of the way is static block.

13. What is final variable?

If you make any variable as final, you cannot change the value of final variable(It will be constant).

14. What is final method?

Final methods can’t be overriden.

15. What is final class?

Final class can’t be inherited.


Continue to: CORE JAVA (FOR AUTOMATION TESTERS) – INTERVIEW QUESTIONS AND ANSWERS – PART 2