Sunday, 29 January 2017

level 2 : 17 Step by step interview question to crack the interview.

IN LEVEL 02 : I WILL USE ALL THE CONCEPT TILL DATE (OOPS, DATA TYPES, INHERITANCE, STATIC, NON- STATIC, OBJECTS  etc.)
1. What will be the output of below code ?
public class callkr {
      
       public void callkr1(Object obj){
              System.out.println("in object method :"+((B)obj).s1);
       }
      
       void callkr1(B b){
              System.out.println("in B method :"+b.s1);
       }
    void callkr1(A a){
       System.out.println("in A method :"+a.s1);
       }
       public static void main(String[] args) {
              A aa=new B();
              new callkr().callkr1(aa);
       }

}


2. What will be the output of the below code ?
class A {public String s1="callkr";
public String show(){
    return "from A : "+s1;
}
}
class B extends A{
       public String s1="javatilldate";
      
       public String show(){
              return "from B : "+s1;
             
       }
}
public class callkr {
      
       public void callkr1(Object obj){
              System.out.println("in object method :"+((B)obj).show());
       }
      
       void callkr1(B b){
              System.out.println("in B method :"+b.show());
       }
    void callkr1(A a){
       System.out.println("in A method :"+a.show());
       }
       public static void main(String[] args) {
              A aa=new B();
              new callkr().callkr1(aa);
       }

}

3. What will be the output of the below code ?
class A {public String s1="calkkr";
public String show(String s1){
    return "from A : "+s1;
}
}
class B extends A{
       public String s1="javatilldate";
      
       public String show(String s1){
              return "from B : "+s1;
             
       }
}
public class callkr {
       static String s1="callkr-again";
      
       public void callkr1(Object obj){
              System.out.println("in object method :"+((B)obj).show(s1));
       }
      
       void callkr1(B b){
              System.out.println("in B method :"+b.show(s1));
       }
    void callkr1(A a){
       System.out.println("in A method :"+a.show(s1));
       }
       public static void main(String[] args) {
              A aa=new B();
              new callkr().callkr1(aa);
       }

}

4. What is Data shadowing ?

5. What is Data Hiding ?

6. What will be the output of the below code ?

class A {public String s1="calkkr";
public String show(String s1){
    return "from A : "+s1;
}
}
class B extends A{
       public String s1="javatilldate";
      
       public String show(String s1){
              return "from B : "+s1;
             
       }
}
public class callkr {
       static String s1="callkr-again";
      
       public void callkr1(Object obj){
              System.out.println("in object method :"+((B)obj).show(s1));
       }
      
       void callkr1(B b){
              System.out.println("in B method :"+b.show(s1));
       }
    void callkr1(A a){
       System.out.println("in A method :"+a.show(s1));
       }
       public static void main(String[] args) {
              A aa=new B();
              aa=null;
              new callkr().callkr1(aa);
       }

}

7. What is java.lang.NullPointerException ?
8. What is dynamic binding ?
9.Can we achieve Dynamic binding with data members ?
10. What will be the output of below code ?
class A {
public String s1="calkkr";
public String show(String s1){
    return "from A : "+s1;
}
}
class B extends A{
       public String s1="javatilldate";
      
       public String show(String s1){
              return "from B : "+s1;
             
       }
      
       public static void main(String[] args) {
              A aa=new B();
             
              System.out.println(aa.s1);
       }
}

Friday, 27 January 2017

level 1 : 16 Step by step interview question to crack the interview.

1.What is overloading in java ?
2.What do you know about method signature ?
3.What do you mean by return type in java ?
4.Can we overload method by changing return type?
   void method(String s){}
   int  method(){return 0;}
5.Can we overload method by changing return type?
   Number method(String s){return 0;}
   Integer  method(){return 0;}
6. What will be the output of below code?
    public class callkr {
       public callkr(){
     System.out.println(" A");
            }
       void callkr(){
     System.out.println(" B");
            }
  public static void main(String[] args) {
     callkr c=new callkr();
            c.callkr();
 }

}

7.Can we overload constructor ?
8.Create your own System.out.println("callkr");
9.When we get ambiguity while overloading a methods ?
10.What is covariant return type in java ?

level 1 : 15 Step by step interview question to crack the interview.

1. Which concept of oops we are using in below code ?
class callkr{
             
              void show(int x){  
                     System.out.println("int-args-method");
              }
              void show(){
                     System.out.println("no-args-method");
              }
}

2. What will be the output if we call new callkr().show();
3  What will be the output if we call new callkr().show(10);
4. What is Overloading in java ?
5. What will be the output of below code ?
class callkr{
             
              void show(int x){  
                     System.out.println("int-args-method");
              }
              void show(long l){
                     System.out.println("no-args-method");
              }
              public static void main(String args[]){
              new callkr().show(10);
              new callkr().show(10l);
       }
}

6. What will be the output of below code ?
class callkr{
             
              void show(float x){  
                     System.out.println("int-args-method");
              }
              void show(long l){
                     System.out.println("no-args-method");
              }
              public static void main(String args[]){
              new callkr().show(10);
              
       }
}


7. What will be the output of below code ?
class callkr{
             
              void show(float x){  
                     System.out.println("int-args-method");
              }
              void show(int x){
                     System.out.println("no-args-method");
              }
              public static void main(String args[]){
              new callkr().show(10l);
              
       }
}

8. What will be the output of below code ?
class callkr{
             
              void show(float x){  
                     System.out.println("int-args-method");
              }
              void show(long l){
                     System.out.println("no-args-method");
              }

              void show(double l){
                     System.out.println("no-args-method");
              }
              public static void main(String args[]){
              new callkr().show(10);
              
       }
}


9. What will be the output of below code ?
class callkr{
             
              void show(int x){  
                     System.out.println("int-args-method");
              }
              void show(long l){
                     System.out.println("no-args-method");
              }

             
              public static void main(String args[]){
              new callkr().show('10');
              
       }
}


10. What will be the output of below code ?
class callkr{
             
              void show(byte x){  
                     System.out.println("int-args-method");
              }
              void show(long l){
                     System.out.println("no-args-method");
              }

             
              public static void main(String args[]){
              byte b=30;
              byte c=20;
              new callkr().show(b-c);
              
       }
}