Pages

Tuesday, June 4, 2019

Java InterView Question

Basic Java and JVM ,OOPS Question :-

 What is Immutability and  how will you create an immutable Class.
Immutable class are those who object once created can't be modified. 
  • No setter :-
  • All field private and Final
  • Declare methods final , not allowing sub class to override its method.
  • If you have mutable Class reference . 
    • Don't all method  to modify the object.
    • Create copies and never return Original mutable object if required. TO achieve this you can do through this way . Code example.

What is Static variable?
Class level variable , All changes at class level and would be reflected to all the .
we access Static variables in a Non-static method ?  vice versa?
Yes, a static variable is accessible to all static and non static method . But Not other way around , mean You can access non static from static method.

What is Dynamic Polymorphism and rules for its implementation?
Overriding
What is Static Polymorphism and rules for its implementation?
Overloading.

What do you mean by a Stack? How will you implement it using an arraylist and linkedlist?
I will go with google definition , a data structure that allows data to be inserted with PUSH operation, and removed using pop operation using LIFO (Last In First Out).
Implementation Code :- Various implementation exist using Quest , Array List, LinkedList etc. we will check ArrayList and LinkedList as in context of java, this is most asked Question.

Reading number from a file and find the duplicates with count? What will be the complexity of your solution?

What do you mean by a singleton class? How will you implement it? How to synchronize it?
PerClassLoader, PerWebApp, PerJVM .
What are Checked Exceptions?
What is Marker Interface?
How will you create an object of a class without using the “new” keyword?
          What is String in java? and related Question
1.       Why string is immutable?  What is string pool in java?  
h1.       Difference between String and String Buffer?
1.      Why char array is better than String for storing password?
1.      Can we compare String using == operator? What is risk?
1.       Does String is thread-safe in Java

1.       How inheritance of generic is different from class inheritance?

Serialization;
1.       What is Externalization and how it is different from serialization?
1.       Changes compatible in serialization?
1.       What is transient in serialization and y we need it?
1.       What is readObject and writeObject method and how it works?


   MultiTHreading :-
1.       What is multithreading?
2.       What is blocking Queue/Linked Queue/Priority Queue?
3.       What is difference between notify and notifyall?
4.       Difference between sleep and wait?
5.       What is cyclic barrier?
6.       What is countdown latch?
7.       What is semaphore?

8.       What is Thread and Runnable?
9.       Why we need Executor Service?*
10.   How to create a deadlock in java and code example?


Collection FrameWork :-
1.       What is collection framework?
2.       List different DS and their properties?
3.       Difference scenario and which one to use?
4.       Internal implementation of array list , Set , Hash  Map.
5.       What is Fail-safe and Fail-fast iterator?
6.       What is Iterator and list Iterator?








1 comment:

  1. The casino site - LuckyClub
    The casino site, a virtual casino site, is a virtual gaming platform by the creators of virtual games. They're both made out of wood, so that you can luckyclub

    ReplyDelete