1 | public class etattva10 {
public static void main(String[] args) {
int i = 10;
int k = 20;
method(i,k);
}
static void method(Integer... i){
System.out.println("Integer varargs is called");
}
static void method(Integer i,Integer j){
System.out.println("Integer,Integer is called");
}
static void method(int... i){
System.out.println("int varargs is called");
}
}
What will be the output for the above program? |
2 | int [] arr = { 1 ,2 ,3 ,4 ,5};
int [] arr2 = new int[4];
arr2 = arr;
System.out.println(arr2[4]);
What is the output of the following ?
|
3 | int [][] arr = new int[3][3];
int [] arr2 = { 1 ,2 };
arr[0] = arr2;
System.out.println( arr[0][0] + " " + arr[0][1] );
What is the output of the following ? |
4 | class customer
{
{
System.out.println("one");
}
static
{
System.out.println("static one");
}
public static void main(String[] args)
{
new customer().run();
}
private customer()
{
{
System.out.println("two");
}
}
{
System.out.println("three");
}
static
{
System.out.println("static two");
}
public void run()
{
System.out.println("baby");
}
}
What is the output of the following ? |
5 |
int[] a = null , b [] = null;
b = a;
System.out.println( b );
What is the output of the following ? |
6 | int []arr = new int[]{1,2,3,4} ;
int []arr2 = new int[]{new Integer(1),2,3,4};
System.out.println( Arrays.equals( arr,arr2 ));
What is the output of the following ? |
7 | int []arr = new int[]{1,2,3,4} ;
String []arrstr = Arrays.toString(arr);
for ( String s : arrstr )
{
System.out.println(s);
}
What is the output of the following ? |
8 | class test
{
public static void main( String args[] )
{
new test().meth(new Integer(42)); // 1
new test<String>().meth("hello"); // 2
new test<String>().meth(new Object() ); // 3
}
public <T>void meth(T type)
{
System.out.println(type);
}
}
Compilation at which line(s) fail ? |
9 | public <T> List<T> meth(List<?> type)
{
System.out.println(type); // 1
return new ArrayList<String>(); // 2
}
what will happen on execution of the code? |
10 | public <T> List<?> house(List<T> sink)
{
System.out.println(sink); // 1
return new ArrayList<String>(); // 2
}
What is the output of the following ? |