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

SCJP认证试题

    博客分类:
  • Java
阅读更多
 /**
 *
 * @author yaoyuan
 */
public class Foo implements Serializable{
    
    public int x, y;
    
    public Foo(int x, int y){
        this.x = x;
        this.y = y;
    }
    
    private void writeObject(ObjectOutputStream s) throws Exception{
        s.writeInt(x);
        s.writeInt(y);
    }
    
    private void readObject(ObjectOutputStream s) throws Exception{
        
    }
}

/**
*which code,inserted ay line 14,will allow this class to correctly serialized
*and desterilize?
*
*A      S.defaultReadObject();
*B This = s.defaultReadObject();
*C y = s.default();    x = s.readInt();
*D x = s.readInt();    y = s.readInt();
*/

// Answer : D


/**
 *
 * @author yaoyuan
 */
String test = "This is a test";
String[] tokens = test.split("\s");
System.out.println(tokens.length);


/**
*
*what is the result ?
*
*
*A 0
*B 1
*C 4
*D Compilation fails
*E An Exception is thrown at runtime
*/

/**Answer: D*/

/*API详解

public String[] split(String regex)

根据给定正则表达式的匹配拆分此字符串。
该方法的作用就像是使用给定的表达式和限制参数 0 来调用两参数 split 方法。因此,所得数组中不包括结尾空字符串。
例如,字符串 "boo:and:foo" 使用这些表达式可生成以下结果:
Regex
结果
:
{ "boo", "and", "foo" }
o
{ "b", "", ":and:f" }
参数:
regex - 定界正则表达式
返回:
字符串数组,它是根据给定正则表达式的匹配拆分此字符串确定的
抛出:
PatternSyntaxException - 如果正则表达式的语法无效
*/

"/s"不是有效的字符串


 /**
 *
 * @author yaoyuan
 */

12. Date date = new Date();
13. df.setLocale(LocalIaly);
14. String s = df.Format(date);


/**
*The variable df is an Object of type DateFormat that has been initialized in line 11.
*What is the result if this code is run on December 142000?
*
*A      The value of S is 14-dic-2004
*B The value of S is Dec 142000
*C An exception is thrown at runtime
*D Compilation fails because of an error in line 13
*/

// Answer : D


DateFormat抽象类没有setLocale(Object object);方法.


/**
*
* @author yaoyuan
*/

The does File Exist method takes an array of directory names representing a path from the root
file system and a file name. The method returns true if the file exists, false if does not.

Place the code fragments in position to complete this method.


/**
* [place here]
* for(String dir : directories){
* [place here]
* }
*
* [place here]
*
* [place here]
*
* }
*
*
* Code fragments
*
* [path=path.getSubdirectory(dir);] [return !file.isNew();] [return (file != null);]
* [String path = "";] [path = path.getFile(filename);] [File path = new File("");]
* [return file.exists();] [return path.isFile();] [File file = new File(path, filename);]
* [path = new File(path, dir);] [File path = new File(File.separator);]
* [path = path + File.separator + dir;]
*
*/




/**	Answer:
*
*	String path = "";
*	for(String dir : directories){
*		path = path + File.separator + dir;
*	}
*	File file = new File(path, filename);
*	return file.exists();
*
*/


/** Example Code:

public class Test {

    public static void main(String[] args) {
        Test test = new Test();
        String[] d = new String[2];
        d[0] = "C:";
        System.out.println(test.doesFileExist(d, "test"));
    }

    public boolean doesFileExist(String[] directories, String filename) {
        String path = "";
        for (String dir : directories) {
            path = path + File.separator + dir;
        }
        System.out.println(path);
        File file = new File(path, filename);
        return file.exists();
    }
}

*
*/



/**
*
* @author yaoyuan
*/



/**
* System.out.println("Pi is approximately %f and E is approximately %b, Math.PI, Math.E");
* place the values where they would appear in the output.
*
* output:
* pi is approximately [place here]
* and E is approximately [place here]
*
*
* Values
* [3] [2] [3.141593] [2.718282] [true]    [false]
* [Math.E] [Math.PI]
*
*/




/** Answer:
*
* Pi is approximately [3.141593]
* and E is approximately [true]
*
*/


/**API详解
* Math.E 比任何其他值都更接近 e(即自然对数的底数)的 double 值。
* Math.PI 比任何其他值都更接近 pi(即圆的周长与直径之比)的 double 值。
*
*/



/**
*
* @author yaoyuan
*/


/**
* When comparing java.io.BufferedWriter to java.io.FileWriter, which capability exist as a method in only
* one of the two?
*
*
*A      close the stream
*B flushing the stream
*C writing to the stream
*D making a location in the stream
*E writing a line separator to the stream
*/

// Answer : E



/**
 *
 * @author yaoyuan
 */
1.public class Main{
2.	public static void main(String[] args){
3.		//[insert Code here]
4.		System.out.println(s);
5.	}
6.}

/**
* Which two code fragments, inserted independently at line 3, generate the output 4247?(choose two)
*
*A      String s = "123456789";
* s = (s-"123").replace(1,3,"24")-"89";
*
*B StringBuffer s= new StringBuffer("123456789");
* s.delete(0, 3);
* s.replace(1,3,"24");
* s.delete(4,6);
*
*C StringBuffer s = new StringBuffer("123456789");
* s.subString(3,6);
* s.delete(1,3);
* s.insert(1,"24");
*
*D StringBuffer s = new StringBuffer("123456789");
* s.subString(3,6);
* s.delete(1,2);
* s.insert(1,"24");
*
*E StringBuffer s = new StringBuffer("123456789");
* s.delete(0,3);
* s.replace(1,3,"");
* s.delete(2,5);
* s.insert(1, "24");
*
*/

// Answer : B E



/**
*
* @author yaoyuan
*/


/**
*Which three statements concerning the use of the java.io.Realizable interface are true?(choose three)
*
*A      Object from classes that use aggregation cannot be serialized
*B An Object serialized on one JVM can be successfully desterilized on a different JVM.
*C The values in fields with the Volatile modifier will not survive serialization and desterilization
*D The values in fields with the transient modifier will not survive serialization and desterilization
*E It is legal to serialize an Object of a type that has a super type that does not implement
* java.io.Serialization
*/

// Answer : B D E


/**
 *
 * @author yaoyuan
 */
public class Main{
	
	public static void go(short n){
		System.out.println("short");
	}
	
	public static void go(short n){
		System.out.println("SHORT");
	}

	public static void go(Long n){
		System.void.println("LONG");
	}

	public static void main(String[] args){
	
		Short y = 6;
		int z = 7;
		go(y);
		go(z);
	}
}


/**
*What is the result?
*
*
*A      shortlong
*B SHORTLONG
*C Compilation fails
*D An exception is thrown at runtime
*/

// Answer : C

go(short n)已经定义



/**
*
* @author yaoyuan
*/

/**
*D is valid,non-null Date object
*df is valid,non-null DateFormat object set to the current local
*
*what outputs the current;local's country name and the appropriate version of d's date
*
*A      Locale loc = new Locale();
* System.out.println(loc.getDisplayCountry());
*
*B Locale loc = new Locale();
* System.out.println(loc.getDisplayCountry() + " " + df.format(d));
*
*C Locale loc = new Locale();
* System.out.println(loc.getDisplayCountry() + " " + df.setDateFormat(d));
*
*D Locale loc = new Locale();
* System.out.println(loc.getDisplayCountry() + " " + df.seDateFormat(d));
*/

// Answer : B







分享到:
评论

相关推荐

    scjp 认证 试题

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

    scjp认证试题.rar

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

    java认证试题 scjp模拟试题

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

    SCJP试题SCJP试题SCJP试题

    关于SCJP(SUN Certified Programmer for the Java SE Platform)试题,这是Java编程语言的一个认证考试,旨在测试应试者对Java基础知识的理解和应用能力。以下是一些相关知识点的详细解释: 1. **方法(Method)**...

    JAVA认证-scjp模拟试题

    本压缩包文件提供了三个部分的"JAVA SCJP认证模拟试题",分别是"SCJP模拟试题(一).doc"、"SCJP模拟试题(二).doc"和"SCJP模拟试题(三).doc",这些文档可能包含了多个章节的练习题目,覆盖了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认证覆盖的知识点广泛,主要包括以下几个方面: 1. **Java语言基础**:这部分内容涉及Java语法、...

    scjp试题 java 认证 考证

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

    JAVA认证 scjp模拟试题.rar

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

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

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

    scjp模拟试题大全

    SCJP(Sun Certified Programmer for the Java 2 Platform, Standard Edition)是Oracle公司为Java程序员提供的一项认证考试,旨在验证考生对Java编程语言的基础知识和理解。这个认证在Java社区中非常受到重视,因为...

    Java scjp考试试题

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

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

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

    scjp模拟试题三套

    SCJP认证考试通常涵盖以下几个核心领域: 1. **Java语法**:包括基本的数据类型、变量、运算符、流程控制(if语句、switch、循环)、方法、类和对象的概念,以及异常处理。理解这些基础知识是编写任何Java程序的...

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

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

Global site tag (gtag.js) - Google Analytics