sokaoti.com
全省北京宇信易诚科技有限公司招聘JAVA笔试模拟题及答案考试专题训练

下面程序创建了一个线程并运行,请填空,使程序完整。

public class ThreadTest {

public static void main (String[] args) {

Hello h=Hew Hello ();

【 】

t.start ();

}

}

class Hello implements Runnable {

int i;

public void run () {

while(true) {

System.out.println("Hello" +i++);

if(i==5) break;

}

}

}


正确答案:Threadt=new Thread(h);
Threadt=new Thread(h); 解析:在通过实现Runnable接口来创建线程以后,该线程的启动将使得对象的run ()方法被调用。题目中缺少线程创建的语句,因此应该填写Thread t=new Thread(h);,该语句创建 Hello类的实例对象h的线程。


以下Java应用程序执行入口main方法的声明中,正确的是( )。

A.public static void main()

B.public static void main(String[] args)

C.public static int main(String[] args)

D.public void main(String[] args)


参考答案:B


下列哪个是对main( )主方法的正确表示?

A.public void static main(String args[ ]){ ... }

B.void public static main(String args[ ]){ ... }

C.static public void main(String args[ ]){ ... }

D.以上都不正确


正确答案:C
解析:在主方法定义时,应注意的是放在主方法前面的返回类型,一般都是void,在往前面是其他修饰符,一般为public和static,这两个修饰符的位置是可以互换的。public表示主方法可以被任意的Java对象访问,static表示该方法是静态方法即只能在类中使用,void是表示主方法没有返回类型,因为Java的类型检查很严格,一般的方法都有适当的返回值,对没有返回值的必须加void说明,每个应用程序必须有且仅有一个主方法。


main方法是Java Application程序执行的入口点,关于main方法头以下( )是合法的。

A.pubUc statk void main()

B.public static void main (String[]args)

C.public static int main (String[]arg)

D.public void main (String arg[])


正确答案:B


main方法是JavaApplication程序执行的入口点。关于main方法的方法头,下列合法的是( )。

A.public static void main()

B. public static void main(String[])args)

C. public static iht main(String[]arg)

D.public void main(String arg[])


正确答案:B


北京宇信易诚科技有限公司招聘JAVA笔试真题及答案选择题 1:鉴于Java的特点,它最适合的计算环境是bA.并行计算环境 B.分布式计算环境 C.高强度计算环境 D.开放式计算环境 2:Which method you define as the starting point of new thread in a class from which new the thread can be excution? bA.public void start() B.public void run() C.public void runnable() D.public static void main(String args) 3:Which statement about listener is true? A 什么是ListenerA.Most component allow multiple listeners to be added. B.If multiple listener be add to a single component, the event only affected one listener. C.Component don?t allow multiple listeners to be add. D.none 4:软件生命周期的瀑布模型把软件项目分为3个阶段、8个子阶段,以下哪一个是正常的开发顺序? aA.计划阶段、开发阶段、运行阶段 B.设计阶段、开发阶段、编码阶段 C.设计阶段、编码阶段、维护阶段 D.计划阶段、编码阶段、测试阶段 5: b 1. Whatwillbeprintedwhenyouexecutethefollowingcode? 2. 3. classX 4. 5. Yb=newY(); 6. X() 7. 8. System.out.print(X); 9. 10. 11. 12. classY 13. 14. Y() 15. 16. System.out.print(Y); 17. 18. 19. 20. publicclassZextendsX 21. 22. Yy=newY(); 23. Z() 24. 25. System.out.print(Z); 26. 27. publicstaticvoidmain(Stringargs) 28. 29. newZ(); 30. 31. 32. 33. Choices:What will be printed when you execute the following code? class X Y b = new Y(); X() System.out.print(X); class Y Y() System.out.print(Y); public class Z extends X Y y = new Y(); Z() System.out.print(Z); public static void main(String args) new Z(); Choices:A.Z B.YZ C.XYZ D.YXYZ 6: c1. Givethefollowingmethod: 2. publicvoidmethod() 3. Stringa,b; 4. a=newString(“helloworld”); 5. b=newString(“gameover”); 6. System.out.println(a+b+”ok”); 7. a=null; 8. a=b; 9. System.out.println(a); 10. 11. Intheabsenceofcompileroptimization,whichistheearliestpointtheobjectareferedisdefinitelyelibiletobegarbagecollection.Give the following method: public void method( ) String a,b; a=new String(“hello world”); b=new String(“game over”); System.out.println(a+b+”ok”); a=null; a=b; System.out.println(a); In the absence of compiler optimization, which is the earliest point the object a refered is definitely elibile to be garbage collection.A.before line 5 B.before line 6 C.before line 7 D.before line 9 7: c1. Whichisthemostappropriatecodesnippetthatcanbeinsertedatline18inthefollowingcode? 2. 3. (Assumethatthecodeiscompiledandrunwithassertionsenabled) 4. 5. 1.importjava.util.*; 6. 7. 2. 8. 9. 3.publicclassAssertTest 10. 11. 4. 12. 13. 5.privateHashMapcctld; 14. 15. 6. 16. 17. 7.publicAssertTest() 18. 19. 8. 20. 21. 9.cctld=newHashMap(); 22. 23. 10.cctld.put(in,India); 24. 25. 11.cctld.put(uk,UnitedKingdom); 26. 27. 12.cctld.put(au,Australia); 28. 29. 13./morecode. 30. 31. 14. 32. 33. 15./othermethods. 34. 35. 16.publicStringgetCountry(String

main方法是Java Application程序执行的入口点,关于main方法头以下( )是合法的。

A.public static void main( )

B.public static void main (String[ ]args)

C.public static int main (String[ ]arg)

D.public void main(String arg[])


正确答案:B


下列( )是对main ()主方法的正确表示。

A.public void static main (String args []) {…}

B.void public static main (String args []) {…}

C.static public void main (String args []) {…}

D.以上都不正确


正确答案:C


以下哪个是Java应用程序main方法的有效定义?

A. public static void main();

B. public static void main( String args );

C. public static void main( String args[] );

D. public static void main( Graphics g );

E. public static boolean main( String a[] );


正确答案:C


以下是JAVA中正确的入口方法是? () 

  • A、 public static void main(String[] args){}
  • B、 public static void main(String args){}
  • C、 public void main(String[] args){}
  • D、 public static int main(String[] args){}

正确答案:A


class MyThread extends Thread {  public void run() { System.out.println(“AAA”); }  public void run(Runnable r) { System.out.println(“BBB”); }  public static void main(String[] args) {  new Thread(new MyThread()).start();  }  }   What is the result?()  

  • A、 AAA
  • B、 BBB
  • C、 Compilation fails.
  • D、 The code runs with no output.

正确答案:A

更多 “全省北京宇信易诚科技有限公司招聘JAVA笔试模拟题及答案考试专题训练” 相关考题
考题 多选题下列有关main()方法的签名正确的是哪些?()Apublic static void main(String[] args){}Bpublic static void main(){}Cpublic static void main(String args[]){}Dpublic void static main(String[] args){}正确答案:D,B解析:暂无解析

考题 单选题class MyThread extends Thread {  public void run() { System.out.println(“AAA”); }  public void run(Runnable r) { System.out.println(“BBB”); }  public static void main(String[] args) {  new Thread(new MyThread()).start();  }  }   What is the result?()AAAABBBBCCompilation fails.DThe code runs with no output.正确答案:B解析:暂无解析

考题 下面哪些选项是正确的main方法说明?()A、 public main(String args[])B、 public static void main(String args[])C、 private static void main(String args[])D、 void main()正确答案:B

考题 声明Java独立应用程序main()方法时,正确表达是()。A、public static void main(String[]args){…}B、private static void main(String args[]){…}C、public void main(String args[]){…}D、public static void main(){…}正确答案:A

考题 public class Threads4 {  public static void main (String[] args) {  new Threads4().go();  }  public void go() {  Runnable r = new Runnable() { public void run() {  System.out.print(”foo”);  }  };  Thread t = new Thread(r);  t.start();  t.start();  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints „foo”.D、 The code executes normally, but nothing is printed.正确答案:B

考题 单选题下面哪些选项是正确的main方法说明?()Apublic main(String args[])Bpublic static void main(String args[])Cprivate static void main(String args[])Dvoid main()正确答案:B解析:暂无解析

考题 下面哪些main方法可用于程序执行()A、public static void main(String[]args)B、public static void main(String[]x)C、public static void main(Stringargs[])D、public void main(String[]args)正确答案:A,B,C

考题 单选题Which method must be defined by a class implementing the java.lang.Runnable interface? ()Avoid run()Bpublic void run()Cpublic void start()Dvoid run(int priority)Epublic void run(int priority)Fpublic void start(int priority)正确答案:A解析:暂无解析

考题 public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints “bar”.D、 The code executes normally, but nothing prints.正确答案:C

考题 多选题下面哪些main方法可用于程序执行()Apublic static void main(String[]args)Bpublic static void main(String[]x)Cpublic static void main(Stringargs[])Dpublic void main(String[]args)正确答案:B,D解析:暂无解析