Submitted by c-admin on Thu, 05/30/2019 - 03:06    
  
  
    Consider the following code:
public class Varargs{   
public void test(){       
 test1(10, 20);  //1   }  
 public void test1(int i, int... j){ 
System.out.println("1"); }   
public void test1(int... i ){ 
System.out.println("2"); }   
public void test1(int i, int j){ 
System.out.println("3"); }   
public static void main(String[] args){     
new Varargs().test();   } }
What will the program print?
Select 1 option 
A. 1 
B. 2 
C. 3 
D. It will not compile. 
E. Exception at runtime.
    
  
  
 
  
        
    
      
      Submitted by c-admin on Thu, 05/30/2019 - 03:01    
  
  
    Given the following pairs of method declarations, which of the statements are true?
1.    void perform_work(int time){ }
 int  perform_work(int time, int speed)         { return time*speed ;} 
2.    void perform_work(int time){ }
 int  perform_work(int speed)     {return speed ;} 
3.    void perform_work(int time){ }
 void Perform_work(int time){ }
Select 2 options
A. The first pair of methods will compile correctly and overload the method 'perform_work'. 
B. The second pair of methods will compile correctly and overload the method 'perform_work'. 
C. The third pair of methods will compile correctly and overload the method 'perform_work'. 
D. The second pair of methods will not compile correctly. 
E. The third pair of methods will not compile correctly. 
    
  
  
 
  
        
    
      
      Submitted by c-admin on Tue, 05/28/2019 - 03:41    
  
  
    Consider the following class.
class TestClass{
void probe(Object x) { System.out.println("In Object"); } //3 
void probe(Number x) { System.out.println("In Number"); } //2 
void probe(Integer x) { System.out.println("In Integer"); } //2 
void probe(Long x) { System.out.println("In Long"); } //4
public static void main(String[] args){ double a = 10;
new TestClass().probe(a);
}
}
What will be printed?
Select 1 option
A. In Number
B. In Object
C. In Long
D. In Integer
E. It will not compile.
    
  
  
 
  
        
    
      
      Submitted by c-admin on Tue, 05/28/2019 - 03:36    
  
  
    Consider the following code:
public class TestClass{
   public void method(Object o){
      System.out.println("Object Version");
   }
   public void method(java.io.FileNotFoundException s){
      System.out.println("java.io.FileNotFoundException Version");
   }
   public void method(java.io.IOException s){
      System.out.println("IOException Version");
   }
   public static void main(String args[]){
      TestClass tc = new TestClass();
      tc.method(null);
   }
}
What would be the output when the above program is compiled and run? (Assume that FileNotFoundException is a subclass of IOException, which in turn is a subclass of Exception)
Select 1 option
A. It will print Object Version
B. It will print java.io.IOException Version
C. It will print java.io.FileNotFoundException Version
D. It will not compile.
E. It will throw an exception at runtime.
    
  
  
 
  
        
    
      
      Submitted by c-admin on Tue, 05/28/2019 - 03:31    
  
  
    What will be printed when the following code is compiled and run?
public class LoadTest{
    public static void main(String[] args) throws Exception {
         LoadTest t = new LoadTest();
         int i = t.getLoad();
         double d = t.getLoad();
         System.out.println( i + d );
    }
    public int getLoad() {
        return 1;
    }
    public double getLoad(){ 
        return 3.0;
    }
}
Select 1 option
A. 13.0
B. 4.0
C. 4 
D. The code will not compile.
    
  
  
 
Pages