Java认证模拟题:TestoftheJavaSkill (4)
来源:优易学  2011-11-28 14:14:47   【优易学:中国教育考试门户网】   资料下载   IT书店

  Question 25:
   What will happen when you attempt to compile and run the following code?

   int Output = 10;
   boolean b1 = false;
   if ((b1==true)&&((Output+=10)==20)){
   System.out.println(“We are equal “ + Output);
   }
   else{
   System.out.println(“Not equal!” + Output);
   }

   A. Compile error, attempting to perform binary comparison on logical data type

   B. Compilation and output of “We are equal 10”

   C. Compilation and output of “Not equal! 20”

   D. Compilation and output of “Not equal! 10”

   Question 26:
   Which of the following are true?

   A. Java uses a time-slicing scheduling system for determining which Thread will execute.

   B. Java uses a pre-emptive, co-operative system for determining which Thread will execute.

   C. Java scheduling is platform dependent and may vary from one implementation to another.

   D. You can set the priority of a Thread in code.
  Question 27:
   What will happen when you attempt to compile and run the following code?

   public class MySwitch{
   public static void main(String argv[]){
   MySwitch ms = new MySwitch();
   ms.amethod();
   }
   public void amethod(){
   int k=10;
   switch(k){
   default:
   System.out.println(“This is the default output”);
   break;
   case 10:
   System.out.println(“ten”);
   case 20:
   System.out.println(“twenty”);
   break;
   }
   }
   }

   A. None of these options

   B. Compile time error target of switch must be an integral type

   C. Compile and run with output “This is the default output”

   D. Compile and run with output “ten”

   Question 28:
   What will happen when you attempt to compile and run the following code?
   public class StrEq{
   public static void main(String argv[]){
   StrEq s = new StrEq();
   }
   private StrEq(){
   String s = “Marcus”;
   String s2 = new String(“Marcus”);
   if (s==s2){
   System.out.println(“we have a match”);
   }else{
   System.out.println(“Not equal”);
   }
   }
   }

   A. Compile time error caused by private constructor

   B. Output of “we have a match”

   C. Output of “Not equal”

   D. Compile time error by attempting to compare string using ==

   Question 29:
   Which of the following will compile correctly?

   A. short myshort = 99S;

   B. String name = ‘Excellent tutorial Mr Green';

   C. char c = 17c;

   D. int z = 015;
   Question 30:
   Which of the following are benefits of encapsulation?

   A. All variables can be manipulated as Objects instead of primitives

   B. By making all variables protected they are protected from accidental corruption

   C. The implementation of a class can be changed without breaking code that uses it

   D. making all methods protected prevents accidental corruption of data

   Question 31:
   Given the following classes which of the following will compile without error?

   interface IFace{}
   class CFace implements IFace{}
   class Base{}

   public class ObRef extends Base{
   public static void main(String argv[]){
   ObRef ob = new ObRef();
   Base b = new Base();
   Object o1 = new Object();
   IFace o2 = new CFace();
   }
   }

   A. o1 = o2;

   B. b = ob;

   C. ob = b;

   D. o1 = b;
   Question 32:
   Your chief software designer has shown you a sketch of the new Computer parts system she is about to create. At the top of the hierarchy is a Class called Computer and under this are two child classes. One is called LinuxPC and one is called WindowsPC. The main difference between the two is that one runs the Linux OS and the other runs the Windows OS (of course another difference is that one needs constant re-booting and the other runs reliably). Under the WindowsPC are two Sub classes one called Server and one Called Workstation. How might you appraise your designers work?

   A. Give the go ahead for further design using the current scheme

   B. Ask for a re-design of the hierarchy with changing the OS to a field rather than Class type

   C. Ask for the option of WindowsPC to be removed as it will soon be obsolete
D. Change the hierarchy to remove the need for the superfluous Computer Class(CN-JAVA)

责任编辑:小草

文章搜索:
 相关文章
热点资讯
热门课程培训