You are on page 1of 5

Ques: 5

public class Gen<T> { Ques: 20


private T object;
public Gen(T object) { package com.sun.cert;
this.object=object; import java.util.*;
} public class AddressBook
public T getObject() {
return object; Ques: 21
}
interface Reloadable
Ques: 6 {
public void reload();
list.add("foo"); - compilation fails }
list=new ArrayList<String>(); - compiles
list=new ArrayList<Object>(); - compilation fails class Edit
String s=list.get(0); - compiles {
Object o=list; - compiles public void Edit(){}
}
Ques: 7
interface Displayable extends Reloadable
ArrayList<String> x1=new ArrayList<String>(); {
-- compiles public void display();
foo(x1); -- fails }

ArrayList<Object> x2=new ArrayList<String>(); Ques: 37


-- fails
foo(x2); -- fails for(int x : y)

ArrayList<Object> x3=new ArrayList<Object>(); Ques: 42


-- compiles
foo(x3); -- compiles BufferedReader reader = new
BufferedReader(new FileReader("in"));
ArrayList x4=new ArrayList(); -- compiles
foo(x4); -- compiles PrintWriter writer = new PrintWriter(new
BufferedWriter(new FileWriter("out")));
Ques: 12
Ques: 49
Alpha:foo Beta:foo Beta:bar Beta:bar
(temp=buffReader.readLine())!=null
Ques: 15
(IOException e){
enum Element
{
EARTH,WIND,FIRE{ Ques: 52
public String info(){
return "Hot"; class A has name A
}
}; class B has name A
public String info()
{ Ques: 53
return "element";
} 1. class A{List<B> b} - car is vechile and car is
} a collectible
2.class A{} - car has a steering wheel
3.class A{B b;} - car has wheels public String getNames() {
4.class A extends B,C{} - Mini is a car return map.keySet()
5.class A{B b;C c;} - car is an object }
6.class A implements B,C{} }
7.class A extends B{}

Ques: 87 Ques: 123

3.14593 public void bar(int x)()

true public int bar(String x){ return 1;}

public void bar(int x,int y){}


Ques: 91
Ques: 124
public boolean doesFileExist(String []dirs,String
filename) same ques 21
{
String path=""; Ques: 139

for(String dir:dirs) Dog is a Animal


{
Forest has a Tree
path=path+File.separator+dir;
Rectangle is a Square
}
System.out.println(path); Java Book is a programming Book
File file = new File(path,filename);
return file.exists();
} Ques: 143
}
public class Single{
private static Single instance;
Ques: 105 public static Single getInstance() {
if(instance==null)instance=create();
package com.bar; return instance;
}
import com.foo.bar.blatz.*; // next 2 line alone changes... ( instead of private
protected and instead of protected static )
import com.foo.bar.*; protected Single() { }
static Single cerate() { return new Single(); }
}
Ques: 106 class SingleSub extends Single {
}
DONT KNOW
Ques: 147
Ques: 113
started
public class NumberNames{ ran
private HashMap<String,Integer> map= new interrupting
HashMap<String,Integer>(); ended
public void put(String name,int value){ (no more output)
map.put(name,value);
} Ques: 151
java.util.List --------> allows access to elements
run() --->java.lang.Thread by their integer index
wait() --->java.lang.Object
notify() --->java.lang.Object java.util.Queue --------> is designed for holding
sleep() --->java.lang.Thread elements prior to processing
start() --->java.lang.Thread
join() --->java.lang.Thread Ques: 191

public class GenericB< Pet extends T > {


public T foo;
public void setFoo ( T foo) {
Ques: 171 this.foo=foo;
}
same ques 52 public T getFoo() {
return foo;
Ques: 177 }
public static void main(String[] args) {
same ques 42 GenericB<Cat> bar = new GenericB< Cat> ();
bar.setFoo(new Cat());
Ques: 180 Cat c= bar.getFoo();
}
same ques 91 }
interface Pet{ }
Ques: 183
class Cat implements Pet { }
while(scanner.hasnext)
{
if(scanner.hasbooleannext) Ques: 195
{
s.o.p(scanner.nextboolean); same ques 7
}
else Ques: 200
scanner.next;
} public int update(int quantity, int adjust){
quantity=quantity + adjust;
Ques: 187 return quantity;

public class myint implements comparable }


public string toString()
public int compareTo(object o) public void callUpdate(){
{
myint i2=(myint)o; int quant=100;
return i2.i-1; quant=update(quant,320);
} system.out.println("quant="+quant;)

}
Ques: 188

java.util.Map --------> defines the method : V Ques: 217


get(Object key)
same ques 123
java.util.Set --------> contains no pair of
elements e1 and e2, such that e1.equals(e2) Ques : 220
public class Flags2 { DONT KNOW
private boolean isReady = false;
public synchronized void produce(){ Ques: 247
isReady = true;
notifyAll(); same ques 187
}
public synchronized void consume() { Ques: 251
while(!isReady) {
try { public class ReadFile{
wait(); public static void main(String argv[]){
}catch(Exception ex){} try{
} File x1 = new File("MyText.txt");
isReady=false; FileReader x2 = new FileReader(x1);
} BufferedReader x4 = new BufferedReader(x2);
} String x3 = null;
while((x3 = x4.readLine()) != null){
System.out.println(x3);
Ques: 222 }x4.close();
}catch(Exception ex){
ex.printStackTrace();
same ques 147 }
}
}
Ques: 223
Ques: 287
t.join();
t.start(); package alpha;
doIt(); public class Alpha{
private String alpha;
public Alpha(){this("A");}
Ques: 238 protected Alpha(String a){alpha = a;}
}
same as 6
package beta;
Ques: 243 public class Beta extends alpha.Alpha{
public Beta(String a){super(a);}
public void takeList(ArrayList list){} - compiles }
public void tkeList(ArrayList<Animal> list){} -
compilation fails
public void takeList(ArrayList<? extends Ques: 288
Animal> list){} - compiles
public void takeList(ArrayList<?> list){} - same ques 139
compiles
public void tkeList(ArrayList<Object> list){} - Ques: 290
compilation fails
same ques 53

Ques: 244 Ques: 305

same ques 113 same ques 287

Ques: 308
Ques: 246
public class Doubler {
public static int doubleMe(int h) same ques 5
{
return h*2; Ques: 362

} java.util.SortedSet->>>>>defines base methods


for an ordered set..
public class Holder {
java.util.Arrays->>>>>provide array
int amount=10; manipulation utilities..
public void
doubleAmount(){amount=Doubler.doubleMe(amount);} java.util.Iterator-->>>>>>defines methods for
leniar access to a collection...
public int getAmount(){return amount;}

} java.util.TreeSet->>>>> provide concrete


implementaion of an ordered set..

java.util.Collection->>>>>defines base methods


Ques: 313 for all collection objects...

same ques 200

Ques: 316

same ques 105

Ques: 323

same ques 220

Ques: 327

same ques 223

Ques: 329

same ques 151

Ques: 335

same ques 49

Ques: 336

same ques 251

Ques: 346

same ques 12

Ques: 353