Professional Documents
Culture Documents
==========
package com.bar;
import com.foo.bar.blatz.*;
import com.foo.bar.*;
Q 21,124
========
interface Reloadable
{
public void reload90;
}
class Edot
{
public void Edit(){}
}
Q113.244
============
import java.util.*;
public class NumberNames
{
private HashMap<String,Integer> map= new HashMap<String,Integer>();
System.out.println(nn.getNames());
}
}
Q 106
=========
import java.util.*;
class A{}
class B extends A{}
m1(listA);
m1(listB);
//m1(listO);
m2(listA);
//m2(listB);
m2(listO);
}
public static void m1(List<? extends A> list){}
public static void m2(List<A> list){}
Q 42,177
========:
Q 49,335
=========:
(temp=buffReader.readLine())!=null
(IOException e){
Q 7,195
==========
import java.util.*;
public class X
{
public static void main(String[] args)
{
Q 6,238
=========
import java.util.*;
public class NumberNames1
{
public void takeList(List<? extends String> list)
{
//list.add("foo");
list=new ArrayList<String>();
//list=new ArrayList<Object>();
String s=list.get(0);
Object o=list;
}
}
Q 12
========:
class Alpha
{
public void foo(String... args)
{
System.out.println("Alpha:foo");
}
public void bar(String a)
{
System.out.println("Alpha:bar");
}
}
a.foo("test");b.foo("test");
a.bar("test");b.bar("test");
}
}
o/p
Alpha:foo
Beta:foo
Beta:bar
Beta:bar
Q15
=====
enum Element
{
EARTH,WIND,FIRE{
public String info(){
return "Hot";
}
};
Q20
=======
package com.sun.cert;
import java.util.*;
public class AddressBook
{
ArrayList entries;
}
Q52
=====
Q 287,305
=========
public
private
public
public
public
public
Q 246
======
import java.util.*;
System.out.println(list.get(0).length());
}
}
Q243
=======
import java.util.*;
class Animal{}
class Dog extends Animal{}
QUESTION # 187,248
====================
public class MyInt implements Comparable {
------
}
public int CompareTo(Object o) {
----
return i-i2.i;
}
EXPLANATION:
sort() method in Collections class uses ompareTo() method of Comparable interface.
so we have to override that compareTo() method. since the o/p should be in
ascending order, i-i2.i is returned.
QUESTION # 143
===============
protected Single() { }
QUESTION # 5
=============
Q;42
===========
Q91,180
==========
public boolean doesFileExist(String []dirs,String filename)
{
String path="";
for(String dir:dirs)
{
Q # 87
=========
Pi is approximately 3.141593
Q 139,288
===========
Dog is-a animal
t.run();
t.join();
t.doIt();
}
public void run()
{
System.out.println(" Run. ");
}
public void doIt()
{
System.out.println(" Doit. ");
}
}
QUESTION # 220,323
=================
public class Flags2
{
private boolean isReady = false;
public synchronized void produce()
{
isReady=true;
notifyAll();
}
public synchronized void consume()
{
while(!isReady)
{
try
{
wait();
}catch(Exception ex){}
}
isReady=false;//I THINK WE MUST PLACE "false" HERE....if we place "true" then
wait() method is never invoked again (isReday's value is always true)
}
}
question 5,353:
===========
public class Gen<T> {
private T object;
public Gen(T object) {
this.object=object;
}
public T getObject() {
return object;
}
question 6,238
===============
public void takeList(List<? extends String> list)
{
//list.add("foo");
list=new ArrayList<String>(); // compiles
//list=new ArrayList<Object>();
String s=list.get(0); // compiles
Object o=list; // compiles
}
Qustion: 7
==============
import java.util.*;
public class X
{
public static void main(String[] args)
{
question 15:
============
enum Element
{
EARTH,WIND,FIRE{
public String info(){
return "Hot";
}
};
public String info()
{
return "element";
}
}
question 20:
==============
package com.sun.cert;
import java.util.*;
public class AddressBook
{
ArrayList entries;
}
question 21:
============
interface Reloadable
{
public void reload();
}
class Edit
{
public void Edit(){}
}
question 37
============
for(int x : y)
question 49,335
===============
(temp=buffReader.readLine())!=null
(IOException e){
question 12:
===============
Alpha:foo Beta:foo Beta:bar Beta:bar
question 52
===============
class A has name A
class B has name A
question 251,336
=============
import java.io.*
question 329,151
================
run() --->java.lang.Thread
wait() --->java.lang.Object
notify() --->java.lang.Object
sleep() --->java.lang.Thread
start() --->java.lang.Thread
join() --->java.lang.Thread
Q200,313
============
public int update(int quantity, int adjust){
quantity=quantity + adjust;
return quantity;
int quant=100;
quant=update(quant,320);
system.out.println("quant="+quant;)
Q-308
=============
public class Doubler {
public static int doubleMe(int h)
{
return h*2;
int amount=10;
public void doubleAmount(amount);}
Q-362
===============
java.util.SortedSet->>>>>defines base methods fr an ordered set..
Q 183
========
Q-188
========
java.util.map===> defines the method: get(Object key)
java.util.Set===> contains no pair of elements e1 and e2 such that e1.equals?(e2)
java.util.List===> allows access to elements by their integer index
java.util.Queue===> is designed for holding elements prior to processing
Q-199
========
T extends Pet
T
T
T
Q-53
=======