没有合适的资源?快使用搜索试试~ 我知道了~
SUN+-+310-025+TopBible.pdf
需积分: 0 0 下载量 162 浏览量
2009-05-09
06:43:27
上传
评论
收藏 343KB PDF 举报
温馨提示
试读
75页
SUN+-+310-025+TopBible.pdf java 考证 用。
资源详情
资源评论
资源推荐
310-025
TOPBIBLE
TOPbible lab. 2001.9
1.public static void main(String args[]) {
Boolean a[]=new Boolean[4];
int I= 1;
System.out.println(a[I]); }
What will be printed?
Compilation Error in Line 2
Compilation Error in line 4
Exception in Line 4
Will print true
Will print false
Will print null
Ans:F
2.
public static void main(String args[]) {
Integer b= new Integer(10);
Add(b);
System.out.println(b.intvalue());
}
void Add(Integer b)
{
int I= b.intvalue();
I+=3;
b= new Integer(I)
}
What will be printed out?
Will print 13
Will print 10
Compilation Error in Line 4 ?. implicit conversion to Integer to
String is not possible
Compilation Error in line 10 you can't re initialize a Wrapper
class
Exception in Line 10
Ans:b
class text{
public static void main(String args[])
{
String a =args[1];
String b =args[2];
String c =args[3];
}
}
if you will execute java text cat dog sheep what will be the value of
the 'c' ?
cat
dog
sheep
Compilation Error
Exception will occur
Ans:E
4. public static void main(String args[])
{
Float f=new Float(4.2f);
Float c;
Double d=new Double(4.2);
float fl=4.2f;
c=f;
}
which will return true?. Select all
f.equls(d)
c==f
c==d
c.equls(f)
Ans:B,D
5. public static void main(String args[])
{
String s;
System.out.println("s = "+s);
}
what will be printed out?
Compilation Error
An Exception will occur
Will print s= null
Will print s=
Ans:A
6. class s extends Thread{int j=0;
public void run() {
try{Thread.sleep(5000);}
catch(Exception e){}
j=100;
}
public static void main(String args[])
{
s t1=new s();
t1.start();
System.out.println(t1.j);
}
}
what you have to do to ensure that 'j' will print 100
you have make t1 as Daemon Thread
You have join the t1 to main
You have to suspend the main when the thread starts and resume it after
the value of 'j' is set to 100
You have to interrupt the main thread
Ans:B
7. What will happen if you compile/run this code?
1: public class Q1 implements Runnable
2: {
3: public void run(String s)
4: {
5: System.out.println("Before start Thread :"+s);
6:
7: System.out.println("After stop of Thread :"+s);
8: }
9:
10: public static void main(String[] args)
11: {
12: Q1 a = new Q1();
13: Thread t=new Thread(a);
14: t.start();}
15: }
A) Compilation error at line 1
B) Runtime exception at line 13.
C) Compilation error at line 14
D) Prints "Before start of Thread "
After Start of Thread
Ans:A
8. class s implements Runnable{
int x=0,y=0;
int addX(){x++; return x;}
int addY(){y++; return y;}
public void run()
{
for(int i=0;i<10;i++)
System.out.println(addX()+""+addY());
}
public static void main(String args[])
{
s run=new s();
Thread t1=new Thread(run);
Thread t2=new Thread(run);
t1.start();
t2.start();
}
}
Compile time Error There is no start method
Will print in this order 11 22 33……
Will print but not exactly in an order (eg: 123124 3……)
Will print in this order 12 3……123……
Will print in this order 123……?.
Ans:C
9.
class s implements Runnable{
int x=0,y=0;
synchronized void addX(){x++; }
synchronized void addY(){y++; }
void addXY(){x++;y++;}
boolean check() { return (x>y)? true:false;)
public void run()
{
////
System.out.println(check()); }
public static void main(String args[])
{ s run=new s();
Thread t1=new Thread(run);
Thread t2=new Thread(run);
t1.start();
t2.start();
}
}
If this methods are called in which order the check will return true?
Select all that apply
call addX() and addY() simultaneously for number of times in run()
call addY() and addX() simultaneously for number of times in run()
all addXY() for number of times in run()
Ans:B,C
10. What is the name of the method used to start a thread execution?
A. init();
B. start();
C. run();
D. resume();
Ans:B
11. Which two methods may not directly cause a thread to stop
executing?
A. sleep();
B. stop();
C. yield();
D. wait();
E. notify();
F. notifyAll()
G. synchronized()
Ans:EF
12. class Outer{
class Inner{}
}
How will you create an instance of Inner Class out side? Select 2
Inner a= new Inner();
Outer o= new Outer();Inner a= new o.Inner();
Outer o= new Outer();Outer.Inner a= new o.Inner();
Outer.Inner a= new Outer().new Inner();
Ans:CD
13. What a static inner class can access select one
剩余74页未读,继续阅读
22222222112
- 粉丝: 1
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0