JAVA题库:格林模拟试题二(下)

日期:12-29| http://www.59wj.com |二级JAVA模拟试题|人气:450

JAVA题库:格林模拟试题二(下) Question 31)
What will happen when you attempt to compile and run the following code
import java.io.*;class Base{  public void amethod()throws FileNotFoundException{}}public class ExcepDemo extends Base{  public static void main(String argv[]){ ExcepDemo e = new ExcepDemo();  }  public void amethod(){}  protected ExcepDemo(){ try{   DataInputStream din = new DataInputStream(System.in);   System.out.println("Pausing");   din.readByte();   System.out.println("Continuing");   this.amethod(); }catch(IOException ioe) {}  }}
1) Compile time error caused by protected constructor
2) Compile time error caused by amethod not declaring Exception
3) Runtime error caused by amethod not declaring Exception
4) Compile and run with output of "Pausing" and "Continuing" after a key is hit


Question 32)

What will happen when you attempt to compile and run this program
public class Outer{public String name = "Outer";public static void main(String argv[]){    Inner i = new Inner();    i.showName();  }//End of main    private class Inner{    String name =new String("Inner");        void showName(){           System.out.println(name);        }    }//End of Inner class}
1) Compile and run with output of "Outer"
2) Compile and run with output of "Inner"
3) Compile time error because Inner is declared as private
4) Compile time error because of the line creating the instance of Inner www.59wj.com Question 33)
What will happen when you attempt to compile and run this code
//Demonstration of event handlingimport java.awt.*;import java.awt.event.*;public class MyWc extends Frame implements WindowListener{public static void main(String argv[]){    MyWc mwc = new MyWc();    }    public void windowClosing(WindowEvent we){        System.exit(0);        }//End of windowClosing   public void  MyWc(){    setSize(300,300);    setVisible(true);    }}//End of class
1) Error at compile time
2) Visible Frame created that that can be closed
3) Compilation but no output at run time
4) Error at compile time because of comment before import statements

Question 34)
Which option most fully describes will happen when you attempt to compile and run the following code
public class MyAr{  public static void main(String argv[]) {    MyAr m = new MyAr();    m.amethod();  }  public void amethod(){    static int i;    System.out.println(i);  }}
1) Compilation and output of the value 0
2) Compile time error because i has not been initialized
3) Compilation and output of null
4) Compile time error 

Question 35)
Which of the following will compile correctly
1) short myshort = 99S;
2) String name = ’Excellent tutorial Mr Green’;
3) char c = 17c;
4)int z = 015; www.59wj.com Question 36)
Which of the following are Java key words
1)double
2)Switch
3)then
4)instanceof
Question 37)

What will be output by the following line?
System.out.println(Math.floor(-2.1));
1) -2
2) 2.0
3) -3
4) -3.0

Question 38)
Given the following main method in a class called Cycle and a command line of
java Cycle one two
what will be output?
public static void main(String bicycle[]){    System.out.println(bicycle[0]);}
1) None of these options
2) cycle
3) one
4) two

Question 39)
Which of the following statements are true?
1) At the root of the collection hierarchy is a class called Collection
2) The collection interface contains a method called enumerator
3) The interator method returns an instance of the Vector class
4) The Set interface is designed for unique elements www.59wj.com Question 40)
Which of the following statements are correct?
1) If multiple listeners are added to a component only events for the last listener added will be processed
2) If multiple listeners are added to a component the events will be processed for all but with no guarantee in the order
3) Adding multiple listeners to a comnponent will cause a compile time error
4) You may remove as well add listeners to a component.

Question 41)
Given the following code
class Base{}public class MyCast extends Base{  static boolean b1=false;  static int i = -1;  static double d = 10.1;  public static void main(String argv[]){    MyCast m = new MyCast();    Base b = new Base();    //Here  }}
Which of the following, if inserted at the comment //Here will allow the code to compile and run without error

1) b=m;
2) m=b;
3) d =i;
4) b1 =i;

Question 42)
Which of the following statements about threading are true
1) You can only obtain a mutually exclusive lock on methods in a class that extends Thread or implements runnable
2) You can obtain a mutually exclusive lock on any object
3) A thread can obtain a mutually exclusive lock on an object by calling a synchronized method on that object.
4) Thread scheduling algorithms are platform dependent

Question 43)
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 operating System and the other runs the Windows System (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?

1) Give the goahead for further design using the current scheme
2) Ask for a re-design of the hierarchy with changing the Operating System to a field rather than Class type
3) Ask for the option of WindowsPC to be removed as it will soon be obsolete
4) Change the hierarchy to remove the need for the superfluous Computer Class. www.59wj.com Question 44)
Which of the following statements are true
1) An inner class may be defined as static
2) There are NO circumstances where an inner class may be defined as private
3) A programmer may only provide one constructor for an anonymous class
4) An inner class may extend another class

Question 45)
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);}
1) Compile error, attempting to peform binary comparison on logical data type
2) Compilation and output of "We are equal 10"
3) Compilation and output of "Not equal! 20"
4) Compilation and output of "Not equal! 10"

Question 46)
Given the following variables which of the following lines will compile without error?
String s = "Hello";long l = 99;double d = 1.11;int i = 1;int j = 0;1) j= i <2) j= i<3) j=i<4)j=i<

Question 47)
What will be output by the following line of code?
System.out.println(010|4);
1) 14
2) 0
3) 6
4) 12 www.59wj.com Question 48)
Given the following variables
char c = ’c’;int i = 10;double d = 10;long l = 1;String s = "Hello";
Which of the following will compile without error?
1)c=c+i;
2)s+=i;
3)i+=s;
4)c+=s;

Question 49)
Which of the following will compile without error?
1) File f = new File("/","autoexec.bat");
2) DataInputStream d = new DataInputStream(System.in);
3) OutputStreamWriter o = new OutputStreamWriter(System.out);
4) RandomAccessFile r = new RandomAccessFile("OutFile");

Question 50)
Given the folowing 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();  }}
1)o1=o2;
2)b=ob;
3)ob=b;
4)o1=b;

Question 51)
Given the following code what will be the output?
class ValHold{    public int i = 10;}public class ObParm{public static void main(String argv[]){    ObParm o = new ObParm();    o.amethod();    }    public void amethod(){        int i = 99;        ValHold v = new ValHold();        v.i=30;        another(v,i);        System.out.print( v.i );    }//End of amethod    public void another(ValHold v, int i){        i=0;        v.i = 20;        ValHold vh = new ValHold();        v =  vh;        System.out.print(v.i);    System.out.print(i);    }//End of another}
1) 10030
2) 20030
3) 209930
4) 10020 www.59wj.com Question 52)
Given the following class definition, which of the following methods could be legally placed after the comment
//Here public class Rid{    public void amethod(int i, String s){}    //Here}
1)public void amethod(String s, int i){}
2)public int amethod(int i, String s){}
3)public void amethod(int i, String mystring){}
4) public void Amethod(int i, String s) {}

Question 53)
Given the following class definition which of the following can be legally placed after the comment line
//Here ?
class Base{public Base(int i){}}public class MyOver extends Base{public static void main(String arg[]){        MyOver m = new MyOver(10);        }    MyOver(int i){        super(i);    }    MyOver(String s, int i){        this(i);        //Here    }}
1)MyOver m = new MyOver();
2)super();
3)this("Hello",10);
4)Base b = new Base(10);

Question 54)
Given the following class definition, which of the following statements would be legal after the comment //Here
class InOut{String s= new String("Between");    public void amethod(final int iArgs){    int iam;       class Bicycle{           public void sayHello(){           //Here           }        }//End of bicycle class    }//End of amethod    public void another(){    int iOther;    }}
1) System.out.println(s);
2) System.out.println(iOther);
3) System.out.println(iam);
4) System.out.println(iArgs); www.59wj.com Question 55)
Which of the following are methods of the Thread class?
1) yield()
2) sleep(long msec)
3) go()
4) stop()

Question 56)
Which of the following methods are members of the Vector class and allow you to input a new element
1) addElement
2) insert
3) append
4) addItem

Question 57)
Which of the following statements are true?
1) Adding more classes via import statements will cause a performance overhead, only import classes you actually use.
2) Under no circumstances can a class be defined with the private modifier
3) A inner class may under some circumstances be defined with the protected modifier
4) An interface cannot be instantiated

Question 58)
Which of the following are correct event handling methods
1) mousePressed(MouseEvent e){}
2) MousePressed(MouseClick e){}
3) functionKey(KeyPress k){}
4) componentAdded(ContainerEvent e){}

Question 59) 
Which of the following are methods of the Collection interface?
1) iterator
2) isEmpty
3) toArray
4) setText

Question 60)
Which of the following best describes the use of the synchronized keyword?
1) Allows two process to run in paralell but to communicate with each other
2) Ensures only one thread at a time may access a method or object
3) Ensures that two or more processes will start and end at the same time
4) Ensures that two or more Threads will start and end at the same time www.59wj.com 如果觉得《JAVA题库:格林模拟试题二(下)》二级JAVA模拟试题,jsj不错,可以推荐给好友哦。

本文Tags: 计算机等级考试 - 模拟试题 - 计算机二级模拟试题 - 二级JAVA模拟试题,jsj,
在百度中搜索相关文章:JAVA题库:格林模拟试题二(下)
在谷歌中搜索相关文章:JAVA题库:格林模拟试题二(下)
在soso中搜索相关文章:JAVA题库:格林模拟试题二(下)
在搜狗中搜索相关文章:JAVA题库:格林模拟试题二(下)
相关分类导航|
热门推荐|