SCJP试题-SCJPMockExam2

来源:java认证发布时间:2012-11-12 12:48:16java认证视频



Question 35)
What will happen when you attempt to compile and run the following code

public class Borley extends Thread{
public static void main(String argv[]){
Borley b = new Borley();
b.start();
}
public void run(){
System.out.println("Running");
}
}
1) Compilation and run but no output
2) Compilation and run with the output "Running"
3) Compile time error with complaint of no Thread target
4) Compile time error with complaint of no access to Thread package

Answer to Question 35)


--------------------------------------------------------------------------------

Question 36)
Assuming any exception handling has been set up, which of the following will create an instance of the RandomAccessFile class

1) RandomAccessFile raf=new RandomAccessFile("myfile.txt","rw");
2) RandomAccessFile raf=new RandomAccessFile( new DataInputStream());
3) RandomAccessFile raf=new RandomAccessFile("myfile.txt");
4) RandomAccessFile raf=new RandomAccessFile( new File("myfile.txt"));

Answer to Question 36)


--------------------------------------------------------------------------------

Question 37)
Given the following class definition

public class Upton{
public static void main(String argv[]){
}
public void amethod(int i){}
//Here
}
Which of the following would be legal to place after the comment //Here ?
1) public int amethod(int z){}
2) public int amethod(int i,int j){return 99;}
3) protected void amethod(long l){ }
4) private void anothermethod(){}

Answer to Question 37)


--------------------------------------------------------------------------------

Question 38)
Which of the following statements are true?

1) Code must be written if the programmer wants a frame to close on selecting the system close menu
2) The default layout for a Frame is the BorderLayout Manager
3) The layout manager for a Frame cannot be changed once it has been assigned
4) The GridBagLayout manager makes extensive use of the the GridBagConstraints class.

Answer to Question 38)


--------------------------------------------------------------------------------

Question 39)
Given the following class definition

public class Droitwich{
class one{
private class two{
public void main(){
System.out.println("two");
}
}
}
}
Which of the following statements are true


1) The code will not compile because the classes are nested to more than one level
2) The code will not compile because class two is marked as private
3) The code will compile and output the string two at runtime
4) The code will compile without error

Answer to Question 39)


--------------------------------------------------------------------------------

Question 40)
Given the following code

class Base{
static int oak=99;
}

public class Doverdale extends Base{
public static void main(String argv[]){
Doverdale d = new Doverdale();
d.amethod();
}
public void amethod(){
//Here
}
}
Which of the following if placed after the comment //Here, will compile and modify the value of the variable oak?

1) super.oak=1;
2) oak=33;
3) Base.oak=22;
4) oak=50.1;

Answer to Question 40)


视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答