Submitted by c-admin on Tue, 05/28/2019 - 03:18    
  
  
    Given:
class OverloadingTest{
void m1(int x){
System.out.println("m1 int");
}
void m1(double x){
System.out.println("m1 double");
}
void m1(String x){
System.out.println("m1 String");
}
}
public class TestClass {
public static void main(String[] args) throws Exception {
OverloadingTest ot = new OverloadingTest();
ot.m1(1.0);
}
}
What will be the output?
Select 1 option
A. It will fail to compile.
B. m1 int
C. m1 double
D. m1 String
    
  
  
 
  
        
    
      
      Submitted by c-admin on Tue, 05/28/2019 - 03:11    
  
  
    Consider the following class...
class TestClass{
void probe(int... x) { System.out.println("In ..."); } //1
void probe(Integer x) { System.out.println("In Integer"); } //2
void probe(long x) { System.out.println("In long"); } //3
void probe(Long x) { System.out.println("In LONG"); } //4
public static void main(String[] args){
Integer a = 4; new TestClass().probe(a); //5
int b = 4; new TestClass().probe(b); //6
}
}
What will it print when compiled and run?
Select 2 options
A. In Integer and In long
B. In ... and In LONG, if //2 and //3 are commented out.
C. In Integer and In ..., if //4 is commented out.
D. It will not compile, if //1, //2, and //3 are commented out.
E. In LONG and In long, if //1 and //2 are commented out.
    
  
  
 
  
        
    
      
      Submitted by c-admin on Tue, 05/28/2019 - 03:06    
  
  
    Which of the following are true regarding overloading of a method?
Select 1 option
A. An overloading method must have a different parameter list and same return type as that of the overloaded method.
B. If there is another method with the same name but with a different number of arguments in a class then that method can be called as overloaded.
C. If there is another method with the same name and same number and type of arguments but with a different return type in a class then that method can be called as overloaded. 
D. An overloaded method means a method with the same name and same number and type of arguments exists in the super class and sub class.
    
  
  
 
  
        
    
      
      Submitted by c-admin on Tue, 05/28/2019 - 03:04    
  
  
    Consider the following class...
class TestClass{
void probe(Integer x) { System.out.println("In Integer"); } //2
void probe(Object x) { System.out.println("In Object"); } //3
void probe(Long x) { System.out.println("In Long"); } //4
public static void main(String[] args){
String a = "hello";
new TestClass().probe(a);
}
}
What will be printed?
Select 1 option
A. In Integer
B. In Object
C. In Long
D. It will not compile
    
  
  
 
  
        
    
      
      Submitted by c-admin on Tue, 05/28/2019 - 02:59    
  
  
    Consider the following method...
public int setVar(int a, int b, float c) { ...}
Which of the following methods correctly overload the above method?
Select 2 options
A. public int setVar(int a, float b, int c){
         return (int)(a + b + c); }
B. public int setVar(int a, float b, int c){
         return this(a, c, b); }
C. public int setVar(int x, int y, float z){
         return x+y); }
D. public float setVar(int a, int b, float c){
        return c*a; }
E. public float setVar(int a){
      return a; }
    
  
  
 
Pages