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.
Pages