`
yuanyao
  • 浏览: 149083 次
  • 性别: Icon_minigender_1
  • 来自: 就那小山沟
社区版块
存档分类
最新评论

SCJP认证试题(三)

    博客分类:
  • Java
阅读更多
/**
*
* @author yaoyuan
*/

/**
*Which three statements are true?(choose three)
*
*A      A final method in class x can be abstract if and only if x is abstract
*B A protected method in class x can be overridden by any subclass of x
*C A private static method can be called only with in other static method in class x
*D A non-static public final method in class x can be overridden in any subclass x
*E A public static method in class x can be called by a subclass of x without explicitly referencing * the class x
*F A method with the same signature as a private final method in class x can be implement entered in * a subclass of x
*/

// Answer : B E F



/**
*
* @author yaoyuan
*/

/**
*Replace two of the Modifiers that appear in the Single class to make the code compile
*
*Note:Three Modifiers will not be used and four midifiers in the code will remain unchanged
*
*/

/**
	Code
*/

public class Single{
	/*private*/ /*static*/ Single instance;
	
	/*public*/ /*static*/ Single getInstance(){
		if(instance == null)
			instance = create();
			return instance;
	}
	
	/*private*/ Single(){
	
	}
	
	/*protected*/ Single create(){
		return new Single();
	}
}

class SingleSub extends Single{
	
}


/**
* Modifiers
*
* final protected private abstract static
*/



// Answer :
//
// public class Single{
// private static Single instance;
//
// public static Single getInstance(){
// if(instance == null)
// instance = create();
// return instance;
// }
// protected Single(){
//
// }
//
// static Single create(){
// return new Single();
// }
// }
//
// class SingleSub extends Single{
//
// }
//
//




 /**
 *
 * @author yaoyuan
 */
public class SimpleCalc{
	public int value;
	
	public void calculate(){
		value += 7;
	}
}

public class Multicalc extends SimpleCalc{
	
	public void calculate(){
		value -= 3;
	}
	
	public void calculate(int multiplier){
		calculate();
		super.calculate();
		value *= multiplier;
	}
	
	public static void main(String[] args){
		Multicalc calculator = new Multicalc();
		calculator.calculate(2);
		System.out.println("Value is :" + calculator.value);
	}

}

/**
*What is the result?
*
*A Value is :8
*B Compilation fails
*C Value is :12
*D Value is :-12
*E The Code is runs with no output
*F An Exception is thrown at runtime
*/

// Answer : A



 /**
 *
 * @author yaoyuan
 */
public class CertkillerCard{

	private String cardID;
	private Integer limit;
	public String ownerName;

	public void setCardInformation(String cardID, String ownerName, Integer limit){
		this.cardID = cardID;
		this.limit = limit;
		this.ownerName = ownerName;
	}

}


/**
*Which statement is true?
*
*
*A      The class is fully encapsulated
*B The code demonstrates polymorphism
*C The ownerName variable breaks encapsulation
*D The cardID and limit variables break polymorphism
*E The setCardInformation method breaks encapsulation
*/

// Answer : C

/**
* encapsulated   封装
* polymorphism   多态
* demonstrates   展示
*/



  /**
 *
 * @author yaoyuan
 */
class Animal{
	public String noise(){
		return "peep";
	}
}

class Dog extends Animal{
	public String noise(){
		return "back";
	}
}

class Cat extends Animal{
	public String noise(){
		return "move";
	}
}

...................
...................
...................

Animal animal = new Dog();
Cat cat = (Cat)animal;
System.out.println(Cat.noise());

/**
*What is the result ?
*
*
*A peep
*B bark
*C move
*D Compilation fails
*E An exception is thrown at runtime
*/

// Answer : E


/**
*
*Cat cat = (Cat)animal;    这行出错了,Dog不能强制转换成Cat对象
*
*/




 /**
 *
 * @author yaoyuan
 */
public class Car{
	private int wheelCount;
	private String vin;
	
	public Car(String vin){
		this.vin = vin;
		this.wheelCount = 4;
	}
	
	public String extend(){
		return "zoom zoom";
	}
	
	public String getInfo(){
		return "VIN:" + vin + "wheels:" + wheelCount;
	}
}

public class MeGo extends Car{
	public MeGo(String vin){
		this.wheelCount = 3;
	}
}


/**
* What two must the programmer do to oerrect the compilation errors?
*
*
*A insert a call to this() in the Car Constructor
*B insert a call to this() in the MeGo Constructor
*C insert a call to super() in the MeGo Constructor
*D insert a call to super(vin) in the MeGo Constructor
*E change the wheelCount variable in Car protected
*F change line 3 in the MeGo class to super wheelCount =3;
*/

// Answer E




  /**
 *
 * @author yaoyuan
 */

10	interface A { public int getValue();}
11	class B implements A{
12		public int getValue(){return 1;}
13	}		
14	class C extends B{	
15		[insert code here]
16	}


/**
*What three code fragments inserted individually at line 15, make use of polymorphism?
*
*
*A      public void add(C c){c.getValue();}
*B public void add(B b){b.getValue();}
*C public void add(A a){a.getValue();}
*D public void add(A a, B b){a.getValue();}
*E public void add(C c1, C c2){c1.getValue();}
*/

// Answer : B C D



 /**
 *
 * @author yaoyuan
 */

11	certkiller = new ReallyBigObject();
12	//more code here
13	certkiller = null;
14	/*insert code here*/


/**
*Which statement should be placed at line 14 to suggest that the virtual machine expend effort tow and recycling the memory used by the Object certkiller?
*
*
*A System.gc();
*B Runtime.gc();
*C System.freeMemory();
*D Runtime.getRuntime() growHeap()
*E Runtime.getRuntime() freeMemory()
*/

// Answer : A


/**
*
* @author yaoyuan
*/


/**
*A developer is creating a class Book, that needs to access class Paper,The Paper class is deployed in a JAR named myLib.jar.
*Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class? (choose three)
*
*
*A      The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar
*B The JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar
*C The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes
* /foo/myLib.jar/Paper.class
*D The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes
* /foo/myLib.jar
*E The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -cp * /foo/myLib.jar Book.java
*
*F The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d * * /foo/myLib.jar Book.java
*
*G The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -classpath * /foo/myLib.jar Book.java
*/

// Answer : B D G



 /**
 *
 * @author yaoyuan
 */
11	class Certkiller{
12		Boochy booch;
13		public Certkiller(){booch = new Boochy(this);}
14	}
15	
16	class Boochy{
17		Certkiller smooch;
18		public Boochy(Certkiller s){smoothy = s;}
19	}
and the statements:
21	public static void main(String[] args){
22		Certkiller snoog = new Certkiller();
23		snoog = null;
24		//more code here
25	}


/**
*Which statement is true about the object referenced by snoog,smooch and booch immediately after line 23 *executes?
*
*
*A None of these objects are eligible for garbage collection
*B only the object referenced by booch is eligible for garbage collection
*C only the object referenced by snoog is eligible for garbage collection
*D only the object referenced by smooch is eligible for garbage collection
*E The Objects referenced by smooch and booch are eligible for garbage collection
*/

// Answer : E








分享到:
评论

相关推荐

    java认证试题 scjp模拟试题

    Java认证,全称为Sun Certified Programmer for the Java 2 Platform, Standard Edition ...以上这些知识点都是SCJP认证考试的重点,通过深入学习和大量练习,考生可以提升自己的Java编程技能,提高通过考试的可能性。

    scjp认证试题.rar

    这个压缩包文件包含了多个与SCJP认证相关的学习资源,包括试题、题库和答案,以及一些重要的复习资料。 1. **SCJP认证概述**:SCJP是Java初学者或初级开发者提升职业资质的重要途径。通过这个认证,开发者可以证明...

    scjp模拟试题三套

    这个“scjp模拟试题三套”压缩包文件包含的资源对于准备SCJP/OCPJP考试的考生来说极其有价值。 SCJP认证考试通常涵盖以下几个核心领域: 1. **Java语法**:包括基本的数据类型、变量、运算符、流程控制(if语句、...

    JAVA认证-scjp模拟试题

    本压缩包文件提供了三个部分的"JAVA SCJP认证模拟试题",分别是"SCJP模拟试题(一).doc"、"SCJP模拟试题(二).doc"和"SCJP模拟试题(三).doc",这些文档可能包含了多个章节的练习题目,覆盖了Java语言的核心概念...

    scjp 认证 试题

    SCJP认证试题通常涵盖以下几个主要领域: 1. **Java语言基础**:包括基本语法、数据类型、变量、运算符、流程控制(如if-else、switch、for、while循环)、方法、数组等。这些是Java编程的基础,理解和熟练掌握它们...

    SCJP认证学习资料

    SCJP认证的学习资料通常会包含详细的理论讲解、实例演示、习题解答和模拟试题,帮助学习者全面掌握这些知识点。通过阅读这5本书,你将有机会深入理解Java语言的各个方面,为SCJP认证考试做好充分准备。同时,不断...

    java scjp模拟试题

    这份"java scjp模拟试题"包含三套模拟测试题,是准备SCJP认证考试的宝贵资源。通过这些试题,考生可以检验自己的知识掌握程度,熟悉考试的格式和题型,提高备考效率。 模拟试题通常涵盖以下几个关键知识点: 1. **...

    SCJP试题,SCJP试题

    SCJP,全称为Sun Certified Programmer for the Java 2 Platform,是Oracle公司(原Sun Microsystems)推出的针对Java程序员的认证考试。这个考试旨在测试考生对于Java SE平台基础编程的知识和技能。以下是一些SCJP...

    SCJP认证试题

    根据给定的文件信息,以下是对“SCJP认证试题”中的关键知识点的详细解析: ### SCJP认证概览 SCJP(Sun Certified Programmer for Java Platform)是Java领域中最具权威的专业程序员认证之一,由Sun Microsystems...

    scjp试题 java 认证 考证

    Java SCJP(SUN Certified Programmer for the Java Platform)是针对Java初学者的一项认证考试,它主要测试考生对Java基础知识的理解和应用能力。...熟悉并掌握这些知识点对于通过SCJP认证考试至关重要。

    JAVA国际认证(SCJP)典型试题1000例

    首先,我们要了解SCJP认证涉及的基础知识: 1. **Java语言基础**:包括数据类型(如整型、浮点型、字符型、布尔型)、变量声明、运算符(算术、关系、逻辑、位、赋值等)、流程控制(if-else、switch、循环、跳转...

    SCJP认证套题解析

    "SCJP认证套题解析"是一个针对这项认证的备考资源,通常包括一系列模拟试题、答案解析以及相关的知识点讲解。 SCJP认证覆盖的知识点广泛,主要包括以下几个方面: 1. **Java语言基础**:这部分内容涉及Java语法、...

    JAVA认证 scjp模拟试题.rar

    总的来说,准备SCJP认证需要系统学习Java语言的核心概念,并通过大量的实践和模拟试题来提高编程能力和应对考试的能力。这个压缩包文件很可能是备考SCJP的一个重要资源,考生应当充分利用其中的资源进行复习和准备。

    scjp模拟试题大全

    接着,"scjp模拟试题(二)思达网校.doc"和"scjp模拟试题(三)思达网校.doc"是另外两套模拟试题,它们同样会涵盖上述主题,但可能包含不同的题目,以提供更多的练习机会。每一套模拟试题都是对考生掌握Java编程概念...

    Java scjp考试试题

    ### Java SCJP考试知识点解析 #### 题目87: 命令行参数解析与输出 **题目描述:** 在给定的代码中,`Test` 类包含了一个 `main` 方法,该方法试图从命令行参数数组 `args` 中获取元素并将其赋值给 `String` 类型的...

    JAVA认证历年真题 SCJP认证套题解析

    【JAVA认证历年真题 SCJP认证套题解析】主要涵盖了JAVA语言的基础知识,包括数据类型、标识符规则、数值类型转换、字符串操作以及对象和类的使用等方面。以下是这些知识点的详细说明: 1. **数据类型**:题目中提到...

    《Java国际认证(SCJP)典型试题1000例 中文版

    首先,SCJP认证是Java程序员入门阶段的重要凭证,它证明了持有者具备编写和调试Java程序的基本技能。这个认证涵盖了语言特性、类库、内存管理以及异常处理等方面的基础知识。 1. **Java语言特性**:书中会涵盖Java...

    SCJP认证指南 第三版

    《SCJP认证指南 第三版》是一本专为准备参加CX-310-065考试的读者设计的权威参考资料。SCJP(Sun Certified Programmer for the Java 2 Platform, Standard Edition)是Oracle公司(原Sun Microsystems)为评估Java...

Global site tag (gtag.js) - Google Analytics