SCJP试题-SCJPMockExam3

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



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

import java.io.*;
class Base{
public static void amethod()throws FileNotFoundException{}
}

public class ExcepDemo extends Base{
public static void main(String argv[]){
ExcepDemo e = new ExcepDemo();
}

public static void amethod(){}
protected ExcepDemo(){
try{
DataInputStream din = new DataInputStream(System.in);
System.out.println("Pausing");
din.readChar();
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

Answer to Question 31)


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

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

Answer to Question to 32


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

Question 33)
What will happen when you attempt to compile and run this code

//Demonstration of event handling

import java.awt.event.*;
import java.awt.*;
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

Answer to Question 33)


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

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

Answer to Question 34)


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

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;

Answer to Question 35)


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

Question 36)
Which of the following are Java key words
1)double
2)Switch
3)then
4)instanceof

Answer to Question 36)


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

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

Answer to Question 37)


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

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

Answer to Question 38)


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

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

Answer to Question 39)


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

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.

Answer to Question 40)


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

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;

Answer to Question 41)


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

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 a synchronized method of an object
4) Thread scheduling algorithms are platform dependent

Answer to Question 42)

视频学习

我考网版权与免责声明

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

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

最近更新

社区交流

考试问答