Questions of Test: SCJP 5 mock Test

< < Prev More >>

11

public <T> List<?> work(List<?> job)
	{
		System.out.println(job); // 1
		return new ArrayList<?>();  // 2
	}
What is the output of the following ?

12

import java.util.*;
class test 
{
	List<? super String> tester = new ArrayList < String >();
	public static void main( String args[] )
	{
		Boss( tester ); // 2
	}

	public static <T> void Boss(List<? super String> type)
	{
		type.add("hi"); // 1
	}	
}
What is the output of the following ?

13

List <? extends String> list = new ArrayList <String > ();
	for ( Object o : list )
	{
		System.out.println(o);
	}

Choose all that are applicable.

14

List <String> list = new ArrayList <String>; // 1
	list.add("Hello"); // 2
	list.add("Vinay"); // 3
	for ( Object o : list ) // 4
	{
		System.out.println(o); // 5
	}

What is the output of the following ?

15

Which of the following are valid declarations of a for in loop that loops through an int array named j ?

16

package com.etattva; 

public class Green {

    

    static void realcolor(float ... f) {

        System.out.println("Realcolor var");

    }

    static void realColor(float f) {

        System.out.println("Realcolor single");

    }

    

    public static void main(String... args) {

        realcolor(12.4);

    }   

} 

What is the output of the following ?

17

package com.etattva; 

import java.util.ArrayList;

import java.util.List; 


class Furniture{

    

}

class Chair extends Furniture{}

class Table extends Furniture{} 


public class Generic {

    

    public static void main(String... args){

        ArrayList<Chair> a1 = new ArrayList<Chair>();

        addme(a1);

    }  

    

    static void addme(List<Furniture> fur){

        

    }    

}

18

package com.etattva; 

class MainTest {

    protected String subject1="Mathematics";   

    

    protected void takeTest1(){

        System.out.println(subject1);       

    }  

} 


public class Test extends MainTest{

   protected String subject1="Geography";

          

    public static void main(String... args) {

        Test test1 = new Test();

              

        test1.takeTest1();                

    }

}

19

package com.etattva; 

class Building {

    private final void show() {

        System.out.println

("Building");

    }

} 


public class TowerOne extends Building {

    protected void show() {

        System.out.println("Tower One");

    }

    

    public static void main(String ... args) {

        TowerOne one1 = new TowerOne();

        one1.show();

    } 

}
What is the output of the following ?

20

package com.etattva; 

class GenericWay<T super Number> {  


  T n;  


  public T show(T n) { 

   return n;  


  }    


}
What is the output of the following ?

< < Prev More >>