• 网络学院
  • IT资讯
  • 操作系统
  • 网络技术
  • 软件应用
  • 办公软件
  • 编程技术
  • 网站架设
  • 数据库类
  • 平面设计
  • 多媒体类
  • 游戏资讯
  • 教学论文
  • 认证考试
SCJP
  站点:
  • 首 页
  • 最新软件
  • 文章教程
  • 国内软件
  • 国外软件
  • 绿色软件
  • 源码下载
  • 字体下载
SCJP Mock Exam 3(2)
软件发布 SCJP Mock Exam 3(2)
网络软件 系统工具 应用软件 联络聊天 图形图像 多媒体类 行业软件 游戏娱乐 编程开发 安全相关 教育教学 数码软件 绿软下载
热门软件: QQ 瑞星 pplive e话通 木马克星 千千静听 office2000 五笔字根 Photoshop 视频分割
返回文章教程首页 >> 认证考试 >> JAVA认证 >> JAVA题库 >> SCJP Mock Exam 3(2)

SCJP Mock Exam 3(2)

添加时间: 2007-9-23 2:09:40  作者: JAVA题库  阅读次数:49   来源: http://www.d9soft.com

       

Question 22)
What can cause a thread to stop executing?

1) The program exits via a call to System.exit(0);
2) Another thread is given a higher priority
3) A call to the thread's stop method.
4) A call to the halt method of the Thread class


Answer to Question 22)

-------------------------------------------
Question 23)
For a class defined inside a method, what rule governs access to the variables of the enclosing method?

1) The class can access any variable
2) The class can only access static variables
3) The class can only access transient variables
4) The class can only access final variables

Answer to Question 23)

--------------------------------------------
Question 24)

Under what circumstances might you use the yield method of the Thread class

1) To call from the currently running thread to allow another thread of the same or higher priority to run
2) To call on a waiting thread to allow it to run
3) To allow a thread of higher priority to run
4) To call from the currently running thread with a parameter designating which thread should be allowed to run

Answer to Question 24)

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

public class Hope{
public static void main(String argv[]){
Hope h = new Hope();
}

protected Hope(){
for(int i =0; i <10; i ++){
System.out.println(i);
}
}
}

1) Compilation error: Constructors cannot be declared protected
2) Run time error: Constructors cannot be declared protected
3) Compilation and running with output 0 to 10
4) Compilation and running with output 0 to 9

Answer to Question 25)

----------------------------------------------
Question 26)
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: //Put the default at the bottom, not here
System.out.println("This is the default output");
break;
case 10:
System.out.println("ten");
case 20:
System.out.println("twenty");
break;
}
}
}
1) None of these options
2) Compile time error target of switch must be an integral type
3) Compile and run with output "This is the default output"
4) Compile and run with output of the single line "ten"

Answer to Question 26)

-------------------------------------------
Question 27)
Which of the following is the correct syntax for suggesting that the JVM performs garbage collection

1) System.free();
2) System.setGarbageCollection();
3) System.out.gc();
4) System.gc();

Answer to Question 27)

--------------------------------------
Question 28)

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

public class As{
int i = 10;
int j;
char z= 1;
boolean b;
public static void main(String argv[]){
As a = new As();
a.amethod();
}
public void amethod(){
System.out.println(j);
System.out.println(b);
}
}

1) Compilation succeeds and at run time an output of 0 and false
2) Compilation succeeds and at run time an output of 0 and true
3) Compile time error b is not initialised
4) Compile time error z must be assigned a char value

Answer to Question 28)

---------------------------------------
Question 29)

What will happen when you attempt to compile and run the following code with the command line "hello there"

public class Arg{
String[] MyArg;
public static void main(String argv[]){
MyArg=argv;
}

public void amethod(){
System.out.println(argv[1]);
}
}
1) Compile time error
2) Compilation and output of "hello"
3) Compilation and output of "there"
4) None of the above

Answer to Question 29)

----------------------------------------
Question 30)
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");
}
}
}
1) Compile time error caused by private constructor
2) Output of "we have a match"
3) Output of "Not equal"
4) Compile time error by attempting to compare strings using ==

Answer to Question 30)

------------------------------------------
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)

-----------------------------------------
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 Linux PC 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.


Answer to Question 43)

------------------------------------------
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) An anonymous class may have only one constructor
4) An inner class may extend another class

Answer to Question 44)

--------------------------------------
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"

Answer to Question 45)

---------------------------------------
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 <
Answer
to Question 46)
------------------------------------

Question 47)
What will be output by the following line of code?
System.out.println(0104);
1) 142) 03) 64) 12
Answer
to Question 47)
----------------------------------

Question 48)
Given the following variableschar 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;
Answer
to Question 48)
-------------------------------------

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");
Answer
to Question 49)
------------------------------------

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;
Answer
to Question 50)
--------------------------------

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.println(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.println(v.i+ " "+i);
}//End of another

}
1) 10,0, 302) 20,0,303) 20,99,304) 10,0,20
Answer
to Question 51)

 

上下文章:

 

上一篇文章: SCJP Mock Exam 3(1) 下一篇文章: SCJP Mock Exam 3(3)

相关文章:

  • Sandy’socp1z0-001Exam
  • SCJP Mock Exam 2(2)
  • SCJP Mock Exam 2(1)
  • SCJP Mock Exam 1(8)
  • SCJP Mock Exam 1(7)

相关软件:

  • ExamDiff Pro V3.3 汉化版
  • ExamDiff V1.6m
  • ExamDiff Pro V3.4 beta 1223
  • Examine32 4.03 汉化版
  • NeoExam考试系统 大众版/ACCESS数据库 1.0.8
  • NeoExam考试系统 VIP版/ACCESS数据库 1.0.8

 

快速导航

  • 网络学院
  • 精品汇聚
  • 字体下载
  • 教程下载
  • ASP源码
  • PHP源码
  • Net源码
  • JSP 源码

JAVA认证分类导航

  • JAVA动态
  • JAVA指导
  • JAVA题库

本类经典文章推荐

  • SCJP模拟试题[2](2)
  • SCJP模拟试题[2](1)
  • SCJP考试真题和解析[1](2)
  • SCJP Mock Exam 3(1)
  • SCJP考试题310-025[5](1)
  • Java网络编程之URI、URL研究专题一
  • Java认证模拟题及分析(1)
  • SCJP模拟试题[1](3)
  • Java认证模拟题及分析(3)
  • SCJP考试真题和解析[2](3)

JAVA题库阅读排行

  • SCJP Mock Exam 2(2)
  • JAVA题库:考考你4
  • JAVA题库:考考你2
  • SCJP考试真题和解析[1](2)
  • Java认证模拟题及分析(3)
  • Java认证模拟题及分析(1)
  • SCJP考试真题和解析[1](1)
  • SCJP模拟试题[2](1)
  • JAVA题库:格林模拟试题一(上)(2)
  • SCJP模拟试题[2](3)

JAVA认证阅读总排行

  • SCJP Mock Exam 2(2)
  • JAVA题库:考考你4
  • JAVA题库:考考你2
  • SCJP考试真题和解析[1](2)
  • Java认证模拟题及分析(3)
  • Java认证模拟题及分析(1)
  • SCJP考试真题和解析[1](1)
  • SCJP模拟试题[2](1)
  • JAVA题库:格林模拟试题一(上)(2)
  • SCJP模拟试题[2](3)

广告位置

字母检索 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 回到顶部

关于我们 | 版权声明 | 免责条款 | 广告联系 | 软件发布 | 下载帮助 | 下载排行 | 网站地图 | 特别鸣谢 | 友情连接

copyright; 2005-2008 D9soft.com 第九软件网 版权所有