/**
*
* @author yaoyuan
*/
10 package com.sun.scjp;
11 public class Geodetics{
12 public static final double DIAMETER = 12756.32; //kilometers
13 }
Which two correctly access the DIAMETER member of the Geodetics class?(choose two)
A import com.sun.scjp.Geodetics;
public class TerraCarta{
public double halfway(){
return Geodetics.DIAMETER/2.0;
}
}
B import static com.sun.scjp.Geodetics;
public class TerraCarta{
public double halfway(){
return DIAMETER/2.0;
}
}
C import static com.sun.scjp.Geodetics.*;
public class TerraCarta{
public double halfway(){
return DIAMETER/2.0;
}
}
D import com.sun.scjp;
public class TerraCarta{
public double halfway(){
return DIAMETER/2.0;
}
}
Answer: A C
/**
*参考静态导入
*/
/**
*
* @author yaoyuan
*/
10 class Line{
11 public static class Point{}
12 }
13
14 class Triangle{
15 //insert code here
16 }
Which code inserted line 15, creates an instance of the Point class defined in Line?
A Point p = new Point();
B Line.Point p = new Line.Point();
C The Point class cannot be in statiated at line 15
D Line l = new Line(); l.Point p = new l.Point();
Answer : B
/**
*
* @author yaoyuan
*/
1 public class Plant{
2 private String name;
3 public Plant(String name){this.name = name;}
4 public String getName(){return name;}
5
1 public class Tree extends Plant{
2 public void growFruit(){}
3 public void dropLeaves(){}
4 }
Which statement is true?
A The code will compile without changes.
B The code will compile if public Tree(){Plant();} is added to the Tree class
C The code will compile if public Plant(){Tree();} is added to the Plant class
D The code will compile if public Plant(){this("fern");} is added to the Plant class
E The code will compile if public Plant(){Plant("fern");} is added to the Plant class
Answer : D
/**
*
* @author yaoyuan
*/
10 public class Bar{
11 static void foo(int x){
12 //insert code here
13 }
14 }
Which two code fragments inserted indepently at line 12, will allow the class to compile?(Choose two)
A foreach(x) System.out.println(z);
B for(int z : x) System.out.println(z);
C while(x.hashNext()) System.out.println(x.next());
D for(int i=0;i<x.length;i++) System.out.println(x[i]);
Answer : B D
/**
*
* @author yaoyuan
*/
1 class ClassA{
2 public int numberOfInstances;
3 protected ClassA(int numberOfInstances){
4 this.numberOfInstances = numberOfInstances;
5 }
6 }
7 public class ExtendedA extends ClassA{
8 private ExtendedA(int numberOfInstances){
9 super(numberOfInstances);
10 }
11 public static void main(String[] args){
12 ExtendedA ext = new ExtendedA(420);
13 System.out.print(ext.numberOfInstances);
14 }
15 }
Which statement is true?
A 420 is the output
B An exception is thrown at runtime
C All constructors must be declared public
D Constructors cannot use the private modifier
E Constructors cannot use the protected modifier
Answer: A
/**
*
* @author yaoyuan
*/
1 public class Base{
2 public static final String FOO = "foo";
3 public static void main(String[] args){
4 Base b = new Base();
5 Sub s = new Sub();
6 System.out.print(Base.FOO);
7 System.out.print(Sub.FOO);
8 System.out.print(b.FOO);
9 System.out.print(s.FOO);
10 System.out.print(((Base)s).FOO);
11 }}
12 class Sub extends Base{public static final String FOO = "bar";}
What is the result?
A foofoofoofoofoo
B foobarfoobarbar
C foobarfoofoofoo
D foobarfoobarfoo
E barbarbarbarbar
F foofoofoobarbar
Answer: D
/**
*
* @author yaoyuan
*/
Which two statements are true about has-a and is-a relationships?(Choose two)
A Inheritance represents an is-a relationship
B Inheritance repersents an has-a relationship
C Interfaces must be use when creating a has-a relationship
D Instance variables can be used when creating a has-a relationship
Answer:A D
/**
*
* @author yaoyuan
*/
1 package geometry;
2 public class Hypotenuse{
3 public InnerTriangle it = new InnerTriangle();
4 class InnerTriangle{
5 public int base;
6 public int height;
7 }
8 }
Which statement is true about the class of an object that can reference the variable base?
A It can be any class
B No class has access to base
C The class must be long to the geometry package
D The class must be a subclass of the class Hypotenuse
Answer: C
/**
*
* @author yaoyuan
*/
1 interface A{public void aMethod();}
2 interface B{public void bMethod();}
3 interface C extends A,B{public void cMethod();}
4 class D implements B{
5 public void bMethod(){}
6 }
7 class E extends D implements C{
8 public void aMethod(){}
9 public void bMethod(){}
10 public void cMethod(){}
11 }
What is the result?
A Compilation fails because of an error in line 3
B Compilation fails because of an error in line 7
C Compilation fails because of an error in line 9
D if you define D e = new E(),then e.bMethod() invokes the version of bMethod() defined in line 5
E if you define D e = (D)(new E()),then bMethod() invokes the version of bMethod() defined in line 5
F if you define D e = (D)(new E()),then bMethod() invokes the version of bMethod() defined in line 9
Answer: F
/**
*
* @author yaoyuan
*/
Which two statements are true?(Choose two)
A An encapsulation,public class promotes re-use
B Classes that share the same interface are always tightly encapsulated
C An encapsulation class allow subclasses to overload methods, but does not allow overriding methods
D An encapsulation class allow programmer to change an implementation without affecting outside code.
Answer:A D
分享到:
- 2008-11-26 10:46
- 浏览 1256
- 评论(0)
- 论坛回复 / 浏览 (0 / 2367)
- 查看更多
相关推荐
scjp认证试题.rar
scjp模拟试题 scjp模拟试题(一) scjp模拟试题(二) scjp模拟试题(三) CSTP真题.pdf
Java scjp认证考试非常重要的题库,很有用的,
SCJP认证试题,精典
SCJP认证套题解析 SCJP认证套题解析 SCJP认证套题解析
试题,能通过的就去试试吧!scjp试题 java认证考证,最基础的哦!
JAVA认证-scjp模拟试题
JAVA认证历年真题 SCJP认证套题60题 含答案和解析
JAVA认证 scjp模拟试题。。。。
JAVA国际认证(SCJP)典型试题1000例,我花了5个大洋买的电子版,现在上传供各位想考SCJP认证的孩子学习,里面例题由简单到难的。
SUN认证的 scjp模拟试题(一),有意向的可以试试
参加sl-275课程培训时老师给的试题 85%以上的覆盖率 这是scjp1.5的试题 它和scjp1.6的试题基本一样
JAVA初级认证考试试题SCJP JAVA初级认证考试试题SCJP
Java国际认证(SCJP)典型试题1000例 高清版 pdf 作者: 施铮 出版社: 电子科技大学出版社 出版年: 2005-8 页数: 493 ISBN: 9787810948142
Java国际认证(SCJP)典型试题1000例+(中文版)
Java国际认证(SCJP)典型试题1000例(中文高清影印版)
JAVA认证-SCJP模拟试题(DOC 79页).rar JAVA认证-SCJP模拟试题(DOC 79页).rar
里面有三套模拟试题。sun公司sjcp认证