May 28, 2020

Java interview questions amazon google microsoft


How to crack java interview ? 

  1. Abstraction in java

           Abstraction means we are exposing only essential parts to user, by hiding non -essential parts. For example car, rather than view individual components of car the user is viewing car as a car itself.
Abstraction is achieved in java through interface & abstract class



      2. What is system in System.out.println(); ?

         System is a class in java inside the package java.lang.package
         out is a static variable of type PrintStream
         println is a method to print message



3. What is system in JDK, JRE, JVM ?

4. Explain public static void main?

        To make java class as a main class
         Its is the entry point of java application
         public ( access specifier )  : method can be acess from anywhere from the application
        static ( keyword ) : static block / method/ keyword can be accessed before object creation
        static variable are class variables (  accessed ClassName.variableName)
        void ( empty) :  method doesnt return anything
        main : method name used to identfy the java as the entry method

5. Explain singleton?

 Only one instance of the class through out the application
 making constructor as private
public access for creation of object through a set method by checking the reference is null or not

6. Static in java?

 Static method : example connection class
Static class : Nested class ( grouping of similar class)
Static variable : can be shared among mutliple class ( example counter variable)
Static block : block of code

class Test {
    static int counter;
   
    // start of static block 
    static {
        counter = 10;
        System.out.println("static block called ");
    }
   
}









No comments:

Post a Comment

Your feedback may help others !!!

Facebook comments