0% found this document useful (0 votes)
9 views4 pages

Interview Questions

Uploaded by

harishcse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Interview Questions

Uploaded by

harishcse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

1)What is array?

Decleration, Construction, initialization

2)length(arrays) vs length()

3)Instance variable(varies from obj to obj)/static variable and local variable

4)vaious memory areas in JVM


Method Area- . Class level binary data including static variables ,
Heap Area - Objects and corresponding instance variables will be stored in Heap
area.
Stack Area- For every method the JVM will create a Runtime stack all method calls
performed by that Thread and corresponding local variables will be stored in that
stack. Every entry in stack is called Stack Frame or Action Record

5)Access Modifiers

6)Final method, Final class and final variable

7)Abstract Method : Even though we don't have implementation still we can declare a
method with abstract modifier.That is abstract methods have only declaration but
not implementation. Hence abstract method declaration should compulsory ends with
semicolon.

8)What is the difference between abstract class and abstract method ?

6)synchronized
1. Synchronized is the modifier applicable for methods and blocks but not for
variables and classes.
2. If a method or block declared with synchronized keyword then at a time only one
thread is allow to execute that method or block on the given object.

7)What is interface?

8)Difference between Interface and Abstract class

9)Method Signature? In java, method signature consists of name of the method


followed by argument types.

10)polymorphism

11)overloading/overriding - In overriding method resolution is always takes care by


JVM based on runtime object hence overriding is also considered as runtime
polymorphism or dynamic polymorphism or late binding.

12)overriding/method hiding

13)Constructor?
1. Object creation is not enough, compulsory we should perform initialization then
only the object is in a position to provide the response properly.
2. Whenever we are creating an object some piece of the code will be executed
automatically to perform initialization of an object this piece of the code is
nothing but constructor.
3. Hence the main objective of constructor is to perform initialization of an
object.

14)Constructor vs instance block vs static block?


Constructor vs Instance Block:
1. Both instance block and constructor will be executed automatically for every
object creation but instance block 1st followed by constructor.
2. The main objective of constructor is to perform initialization of an object.
3. Other than initialization if we want to perform any activity for every object
creation we have to define that activity inside instance block.

Static Block:
1)Static blocks will be executed at the time of class loading hence if we want to
perform any activity at the time of class loading, we have to define that activity
inside static block.
2)Within a class we can take any no. Of static blocks and all these static blocks
will be executed from top to bottom.

15)Default exception handling?


1. If an exception raised inside any method then that method is responsible to
create Exception object with the following information.
1. Name of the exception.
2. Description of the exception.
3. Location of the exception.(StackTrace)
2. After creating that Exception object, the method handovers that object to the
JVM.
3. JVM checks whether the method contains any exception handling code or not. If
method won't contain any handling code then JVM terminates that method abnormally
and removes corresponding entry form the stack.
4. JVM identifies the caller method and checks whether the caller method contain
any handling code or not. If the caller method also does not contain handling code
then JVM terminates that caller method also abnormally and removes corresponding
entry from the stack.
5. This process will be continued until main() method and if the main() method also
doesn't contain any exception handling code then JVM terminates main() method also
and removes corresponding entry from the stack.
6. Then JVM handovers the responsibility of exception handling to the default
exception handler.
7. Default exception handler just print exception information to the console in the
following format and terminates the program abnormally.

16)Exception Hirarchy

17)Checked Exceptions vs Unchecked Exceptions:

Checked Exceptions : The exceptions which are checked by the compiler whether
programmer
handling or not, for smooth execution of the program at runtime, are called checked
exceptions.
Example :
FileNotFoundException

Unchecked Exceptions : The exceptions which are not checked by the compiler whether
programmer
handing or not, are called unchecked exceptions.
Example :
ArithmeticException
NullPointerException

18)final/finally/finalize
final:
• final is the modifier applicable for classes, methods and variables.
• If a class declared as the final then child class creation is not possible.
• If a method declared as the final then overriding of that method is not
possible.
• If a variable declared as the final then reassignment is not possible.
finally:
• finally is the block always associated with try-catch to maintain clean up
code which should be executed always irrespective of whether exception raised or
not raised and whether handled or not handled.
finalize:
• finalize is a method, always invoked by Garbage Collector just before
destroying
an object to perform cleanup activities.
19)throw and throws keyword
Throw Keyword:
Sometimes we can create Exception object explicitly and we can hand over to the JVM
manually by using throw keyword.

Throws Statement:
In our program if there is any chance of raising checked exception then compulsory
we should handle either by try catch or by throws keyword otherwise the code won't
compile.

20)Srting/StringBuffer/StringBuilder
1. If the content is fixed and won't change frequently then we should go for
String.
2. If the content will change frequently but Thread safety is required then we
should go for StringBuffer.
3. If the content will change frequently and Thread safety is not required then we
should go for StringBuilder.

21)Difference between == and .equals()

22)important classes in java.lang package?

23)methods in object class

24)String Constant Pool

24)String s=new String("Bhaskar");


String s="Bhaskar";

What is the differnce between above 2 statements? Go through String Constant Pool
concepts

25)Wrapper Classes

26)Autoboxing and Autounboxing?

27)BufferedReader and PrintWriter?

28)Serialization?

28)Collections, cursors

29)Generics

30)application.yaml

31)pom.xml

32)dependencies
33)@value

34) https://www.javatpoint.com/java-programs

You might also like