| 网站首页 | 考讯中心 | 下载中心 | 图片中心 | 缺书预定 | 无忧书城 | 试题试卷 | 校园供求 | 考试大纲 | 企业招聘 | 论文 | 
 | 试曾相逢 | 高校招生 | 培训招生 | 移动视屏 | 短信商务 | 网址导航 | 合作加盟 | 配送范围 | 
您现在的位置: 无忧考试网 >> 试题试卷 >> IT认证 >> sun认证 >> 正文
SCJP真题回忆         ★★★ 【字体:
SCJP真题回忆
作者:佚名    文章来源:www.51kaoshi.cn    点击数:    更新时间:2008-9-12    

PART 1
  
   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
   A. Any variables in the enclosing scope
   B. Final variables in the enclosing scope
   C. Static variables declared in side the method
   D. Static variables declared in side the outer class
   Ans:D
  
   14. What is true about inner class? Select one
   an Inner class can access all variables in the any enclosing scope
   an Inner class can access all variables in the enclosing scope
   an inner class can be declared as private
   an Anonymous inner class can be extended from class and can implement
   an interface
  
   Ans:C
  
   15. A ----- is a class that is a collection which cannot contain any
   duplicate elements which maintains its elements in ascending order.
   SortedSet
   Set
   Sorted Map
   Collection
   TreeSet
  
   Ans: A
  
   16. What is true about Map select one
   A map will order the elements in an order according the key
   A map will use unique key to store value
   A map will use unique key to identify value inside the map
   Ans:C
   17. Which Method Returns the parent part of the pathname of this File
   object, or null if the name has no parent part?
   getParent()
   getParentDir()
   getParentDirectory()
   parentDirectory()
  
   Ans:a
  
   18. Which class should be used in situations that require writing
   characters rather than bytes.
   LineNumberWriter
   PrintWriter
   PrintStream
   PrintOutputReader
   Ans:B
  
   19. To Write End of a File f=new File(C:\\hello.txt");
   new RandomAccessFile(f,"rw").writeByte(?;
   FileInputStream fis=new FileInputStream(f,true);
   DataInputStream d=new DatainputStream(fis);
   d.writeBytes(?
   FilterInputStream fis=new FilterInputStream(f,true);
   DataInputStream d=new DatainputStream(fis);
   d.writeBytes(?
   D. FileOutputStream fis=new FileOutputStream(f);
   DataOutputStream d=new DataOutputStream(fis);
   d.writeBytes(?
   E. FilterOutputStream fis=new FilterOutputStream(f);
   DataOutputStream d=new DataOutputStream(fis);
   d.writeBytes(?
  
   Ans:C
   //Random access file needs to use seek() in order to write last
  
   20. Which of the following is the correct form of constructor for
   PrintWriter?
   new PrintWriter(new OutputStreamReader(new File(".\hai.txt");
   new PrintWriter(new File(".\hai.txt");
   new PrintWriter(new OutputStream());
   21. What is the return-type of the getSource of ActionEvent?
   A. boolean
   B. Boolean
   C. void
   D. ID of the event
   E. Object
  
   Ans:E
   22. To Retrieve the cosine which method you will use?
   cos
   cosine
   getCos
   getCosine
  
   Ans:A
   23. Which class is handling Events for MouseMotionListener?
   MouseMotionEvent
   MouseEvent
   MotionEvent
   ActionEvent
   Ans:B
  
   24. Which of the following will create an empty file. select 2
   FileInputStream
   RandomAccessFile is constructed as "rw".
   FileOutputStream.
   Ans:A,B
  
   25. import java.util.Stack;
   public class aClass
   {
   public static void main(String []agrs)
   {
   Stack st1 = new Stack();
   Stack st2 = new Stack();
   new aClass().Method(st1, st2);
   System.out.println("st1 has: " + st1);
   System.out.println("st2 has: " + st2);
   }
   private void Method(Stack st1,Stack st2)
   {
   st2.push(new Integer(100));
   st1 = st2;
   }
   }
   A. print
   st1 has: []
   st2 has: [100]
   B. error in st1 = st2
   C. error in ("st1 has: " + st1)
   D. print
   st1 has: [100]
   st2 has: [100]
   Ans:A
  
   26. class Super
   {
   int i=0;
   Super(String s)
   {
   i=10;
   }
   }
   class Sub extends Super
   {
   Sub(String s)
   { i=20; }

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

文章录入:ldpldp123123    责任编辑:考试侠 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      相关文章
    CCNA学习、备考全面剖析
    全国英语等级考试(PETS)二级模拟试题一及答案
    全国公共英语等级考试四级全真模拟试卷
    2008年3月全国英语等级考试三级真题及解析
    2006年9月英语等级考试(PETS)一级笔试参考答案
    2006年9月英语等级考试(PETS)一级笔试真题
    2006年3月英语等级考试(PETS)一级笔试参考答案
    2006年3月英语等级考试(PETS)一级笔试真题
    2005年9月英语等级考试(PETS)一级笔试参考答案
    2005年9月英语等级考试(PETS)一级笔试真题
     
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    购书步骤:注册或登录->选购->加入购物车->去收银台->确认收货人信息->选付款方式->选配送方式->下单后汇款->汇款确认->发货->完成
      [如何申请一网通?]  1.只要是招行“一卡通”用户即可免费开通网上支付功能,有二种方式可选择:
    我的账户 付款方式 服务保证 客户服务 联系我们 订购方式 加盟联锁
    ·收 藏 架
    ·定单查询
    ·我的帐户
    ·付款方式

    ·交易条款

    ·运输说明
    ·购物流程
    ·常见问题
    ·保密与安全
    ·顾客反馈
    ·挂号邮寄时间表
    ·售后服务
    ·关于我们
    ·我们的工作时间
    ·送货方式及费率
    ·网上订购
    ·电话订购
    ·邮寄订购
    ·广告合作
    ·网上书店系统
    ·加盟协议书
    点击申请点击申请点击申请点击申请

    网站简介 -- 联系我们 -- 广告联系 -- 诚邀加盟 --设为首页 -- 加入收藏 -- 友情链接


    Copyright @ 2003-2007 武汉市无忧考试版权所有
    客服QQ:有事点这里
    lixiang@51kaoshi.com(业务咨询)whlxsd@126.com(技术支持)点击这里联系我
    门市地址:武汉市武昌区水果湖东三路理想书店 电话:027-87893611 027-62209348
    办公地址:武汉市武昌区欧式街G栋三楼 联系电话:027-87128976 夜间值班电话:027-87271543
    鄂ICP备06008026号