Wednesday, August 3, 2022

Questions Asked in TCS - java interview

1. Explain oops pillars
Object-oriented programming generally referred to as OOPS is the backbone of java as java being a completely object-oriented language. Java organizes a program around the various objects and well-defined interfaces. There are four pillars been here in OOPS which are listed below. These concepts aim to implement real-world entities in programs.
Abstraction
Encapsulation
Inheritance
Polymorphism
Pillars of OOPS

2. What is polymorphism?
Polymorphism in Java is a concept by which we can perform a single action in different ways. Polymorphism is derived from 2 Greek words: poly and morphs. The word "poly" means many and "morphs" means forms. So polymorphism means many forms.
There are two types of polymorphism in Java: compile-time polymorphism and runtime polymorphism. We can perform polymorphism in java by method overloading and method overriding.

3.What is static?
The static keyword in Java is used for memory management mainly. We can apply static keyword with variables, methods, blocks and nested classes. The static keyword belongs to the class than an instance of the class.
The static can be:
Variable (also known as a class variable)
Method (also known as a class method)
Block
Nested class
To learn more Static in java

What is final keyword?
The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be:
variable
If you make any variable as final, you cannot change the value of final variable(It will be constant).
method
If you make any method as final, you cannot override it.
class
If you make any class as final, you cannot extend it.

Explain exception hierarchy?

Explain multiple catch block?
Until 1.6 version ,Eventhough Multiple Exceptions having same handling code we have to write a separate catch block for every exceptions, it increases length of the code and reviews readability
try{
-----------------
-----------------
}
catch(ArithmeticException e) {
e.printStackTrace();
}
catch(NullPointerException e) {
e.printStackTrace();
}
catch(ClassCastException e) {
System.out.println(e.getMessage());
}
catch(IOException e) {
System.out.println(e.getMessage());
}
To overcome this problem Sun People introduced "Multi catch block" concept in 1.7 version.
The main advantage of multi catch block is we can write a single catch block , which can handle multiple different exceptions
In multi catch block, there should not be any relation between Exception types(either child to parent Or parent to child Or same type , otherwise we will get Compile time error )











Explain finally block?
Difference between string buffer and String builder?
Explain beahvaior of final variable with respect to class and method
Write streams code to filter out list on some condition?
What is your approach when ther is production issue ?
Difference between set and list
What is composite key in sql?
What is JPA?
Tell me some hibernate annotations you know?
What is Multi threading? Explain Chain of Responsibility Design Pattern?
What is Spring --Inversion of Control Design Pattern?

Most asked Java Interview Questions

Java is widely used programming language.he programming language is preferred not only by seasoned experts but also pursued by those new to the programming world. So, here are top interview questions on Java and answers that will help you land a good job with java technology. Also it will enhance your learning.The Java interview questions are recommended for both beginners and professionals as well as for Software Developers. You will get company wise quick interview questions guide. Let's get on to the questions.... Here I am providing some important java interview questions with answers and reference to read.

Questions Asked in TCS - java interview

1. Explain oops pillars Object-oriented programming generally referred to as OOPS is the backbone of java as java being a completely obje...