论坛首页 入门技术论坛

SCJP认证试题(五)

浏览 2794 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-11-18   最后修改:2008-11-20
 /**
 *
 * @author yaoyuan
 */

public class CertKiller{
	int x = 12;
	
	public void method(int x){
		x += x;
		System.out.println(x);
	}
}

Given the exhibit:
21	test t= new CertKiller();
22	t.method(5);


/**
*What is the ouput from line 5 of the CertKiller class?
*
*
*A 5
*B 10
*C 12
*D 17
*E 24
*/

//Answer B

 /**
 *
 * @author yaoyuan
 */

10	class CertKiller1{
11		public CertKiller1 Foo(){ return this;}
12	}
13	class CertKiller2 extends CertKiller1{
14		public CertKiller1 Foo(){return this;}
15	}
16	class CertKiller3 extends CertKiller2{
17		//insert code here
18	}

/**

*Which two methods, inserted individually , correctlly complete the CertKiller3 class?(choose two)
*
*
*A public void foo(){}
*B public int foo(){return 3;}
*C public CertKiller2 foo(){return this;}
*D public CertKiller1 foo(){return this;}
*/


//Answer: C D

 /**
 *
 * @author yaoyuan
 */

11	public class Bootchy{
12		int bootch;
13		String snootch;
14	
15		public Bootchy(){
16			this("snootchy");
17			System.out.print("First " );
18		}
19
20		public Bootchy(String snootch){
21			this(420, "snootchy");
22			System.out.print("Second ");
23		}
24		
25		public Bootchy(int bootch, String snoothy){
26			this.bootch = bootch;
27			this.snootch = snootch;
28			System.out.print("Third ");
29		}
30
31		public static void main(String[] args){
32			Bootchy b = new Bootchy();
33			System.out.print(b.snootch + " " + b.bootch);
34		}
35	}

/**
*What is the result?
*
*
*A snootchy 420 Third Second First
*B snootchy 420 First Second Third
*C First Second Third snootchy 420
*D Third Second First snootchy 420
*E Third First Second snootchy 420
*F First Second First Third snootchy 420
*/

//Answer D


 /**
 *
 * @author yaoyuan
 */

11	public static void main(String[] args){
12		Object obj = new int[]{1,2,3};
13		int[] someArray = (int[])obj;
14		for(int I : someArray)  System.out.print(I + " ");
15	}


/**
*What is the result?
*
*A 1 2 3
*B Compilition fails because of an error in line 12
*C Compilition fails because of an error in line 13
*D Compilition fails because of an error in line 14
*E A ClassCaseException is thrown at runtime
*/

//Answer : A


/**
*
* @author yaoyuan
*/

/**
*A Java Bean component has the following field:
*11.PRIVATE BOOLEAN ENABLED;
*Which two pairs of method declarations follow the javabean standard for accessing this field?(choose two)
*
*
*A public void setEnabled(Boolean enabled)
* public Boolean getEnabled()
*B public void setEnabled(Boolean enabled)
* public void isEnabled()
*C public void setEnabled(Boolean enabled)
* public Boolean isEnable()
*D public void setEnabled(Boolean enabled)
* public Boolean getEnabled()
*/


//Answer: A C



/**
*
* @author yaoyuan
*/

10	class CertKiller{
11		static void alpha(){/*more code here*/}
12		void beta(){/*more code here*/}
13	}


/**
*Which two statements are true?
*
*
*A CertKiller.beta() is valid invocation of beta()
*B CertKiller.alpha() is valid invocation of alpha()
*C Method beta() can directly call method alpha()
*D Method alpha() can directly call method beta()
*/

//Anwser : B C



 /**
 *
 * @author yaoyuan
 */

public abstract class Shape{
	private int x;
	private int y;
	
	public abstract void draw();

	public void setAnchor(int x, int y){
		this.x = x;
		this.y = y;
	}
}


/**
*Which two classes use the Shape class correctly?(choose two)
*
*A public class Circle implements Shape{
* private int radius;
* }
*B public abstract class Circle extends Shape{
* private int radius;
* }
*C public class Circle extends Shape{
* private int radius;
* public void draw();
* }
*D public abstract class Circle implements Shape{
* private int radius;
* public void draw();
* }
*E public class Circle extends Shape{
* private int radius;
* public void draw(){/*code here*/}
* }
*F public abstract class Circle implements Shape{
* private int radius;
* public void draw(){/*code here*/}
* }
*/


//Answer: B E



 /**
 *
 * @author yaoyuan
 */
11	static class A {
12		void process() throws Exception{throw new Exception();}
13	}

14	static class B extends A{
15		void process(){System.out.println("B");}
16	}
17	public static void main(String[] args){
18		A a = new A();
19		A.process();
20	}

/**
*What is result
*
*
*
*A B
*B The code exception is thrown at runtime
*C The code run with no output
*D Compilition fails because of an error in line 15
*E Compilition fails because of an error in line 18
*F Compilition fails because of an error in line 19
*
*/


//Answer : F



 /**
 *
 * @author yaoyuan
 */
33	try{
34		//some code here
35	}catch(NullPointerException e1){
36		System.out.print("a");
37	}catch(RuntimeException e2){
38		System.out.print("b");
39	}finally{
40		System.out.print("c");
41	}

/**
*What is the result if NullPointerException occurs on line 34?
*
*A c
*B a
*C ab
*D ac
*E bc
*F abc
*/


//Answer : D



 /**
 *
 * @author yaoyuan
 */

10	public class CertKiller{
11		static int[] a;
12		static {a[0] = 2;}
13		public static void main(String[] args){}
14	}


/**
*Which exception or error will be thrown when a programmer attempts to run this code?
*
*A java.lang.StackOverflowError
*B java.lang.IllegalStateException
*C java.lang.Exceptio0nInInitoatializerError
*D java.lang.ArrayIndexOutOfBoundsException
*
*/


//Answer : C
   发表时间:2008-11-18  
倒数第三道题目,哪里有line19?
倒数第四题答案B一看就是错的,你实现了一个抽象类??
不过还是谢谢楼主放出SCJP题目,最近正想考个玩儿玩
0 请登录后投票
   发表时间:2008-11-20  
谢谢iranger的支持,最近时间特紧,什么都赶到一起去了,SCJP的题目也赶时间,写的匆忙,有很多问题,请见谅啊.....
0 请登录后投票
   发表时间:2008-11-20  
KAO,运行一遍不就都知道了?这种考试好无聊。
0 请登录后投票
   发表时间:2008-11-20  
这位大哥,你刚学java的时候,敢这么嚣张吗??还运行,佩服,佩服.....
0 请登录后投票
   发表时间:2008-11-20  
cats_tiger 写道
KAO,运行一遍不就都知道了?这种考试好无聊。


SCJP还可以的,大多数通过SCJP的人java基本功都还不错。
0 请登录后投票
   发表时间:2008-12-18  
倒数第六题,选项A和选项D有啥区别?恕我眼拙,没看出来
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics