ocjp認證試題
QUESTION 177 Given:
class TestException extends Exception { }
class A {
public String sayHello(String name) throws TestException {
if(name == null) throw new TestException();
return "Hello " + name;
}
}
public class TestA {
public static void main(String[] args) {
new A().sayHello("Aiko");
}
}
Whichstatement is true?
A. Compilation succeeds.
B. Class A does not compile.
C. The method declared on line 9 cannot be modified to throwTestException.
D. TestA compiles if line 10 is enclosed in a try/catch blockthat catches TestException.
Answer: D
Section: (none)
Explanation/Reference:Explanation:
QUESTION 178 Given:
public static void main(String[] args) {
for (int i = 0; i <= 10; i++) {
if (i > 6) break;
}
System.out.println(i);
}
Whatis the result?
A. 6
B. 7
C. 10
D. 11
E. Compilation fails.
F. An exception is thrown at runtime.
Answer: E
Section: (none)
Explanation/Reference:Explanation:
QUESTION 179 Given:
public class Breaker {
static String o = "";
public static void main(String[] args) {
z:
o = o + 2;
for(int x = 3; x < 8; x++) {
if(x==4) break;
if(x==6) break z;
o = o + x;
}
System.out.println(o);
}
}
Whatis the result?
A. 23
B. 234C. 235
D. 2345 E. 2357
F. 23457
G. Compilation fails.
Answer: G
Section: (none)
Explanation/Reference:Explanation:
QUESTION 180 Given:
class A {
void foo() throws Exception { throw new Exception(); }
}
class SubB2 extends A {
void foo() { System.out.println("B "); }
}
class Tester {
public static void main(String[] args) {
A a = new SubB2();
a.foo();
}
}
Whatis the result?
A. B
B. B, followed by an Exception.
C. Compilation fails due to an error on line 9.
D. Compilation fails due to an error on line 14.
E. An Exception is thrown with no other output.
Answer: D
Section: (none)
Explanation/Reference:Explanation:
QUESTION 181 Given:
public static void main(String[] args) {
String str = "null";
if (str == null) {
System.out.println("null");
} else (str.length() == 0) {
System.out.println("zero");
} else {
System.out.println("some");
}
}
Whatis the result?
A. null
B. zero
C. some
D. Compilation fails.
E. An exception is thrown at runtime.
Answer: D
Section: (none)
Explanation/Reference:Explanation:
QUESTION182 Given:
public class Mule {
public static void main(String[] args) {
boolean assert = true;
if(assert) {
System.out.println("assert is true");
}
}
}
Whichcommand-line invocations will compile?
A. javac Mule.java
B. javac -source 1.3 Mule.javaC. javac-source 1.4 Mule.java
D. javac -source 1.5 Mule.java
Answer: B
Section: (none)
Explanation/Reference:Explanation:
QUESTION 183 Given:
static void test() {
try {
String x = null;
System.out.print(x.toString() + " ");
}
finally { System.out.print("finally "); }
}
public static void main(String[] args) {
try { test(); }
catch (Exception ex) { System.out.print("exception"); }
}
Whatis the result?
A. null
B. finally
C. null finallyD. Compilation fails.
E.finally exception
Answer: E
Section: (none)
Explanation/Reference:Explanation:
QUESTION 184 Given:
public class Boxer1{
Integer i;
int x;
public Boxer1(int y) {
x = i+y;
System.out.println(x);
}
public static void main(String[] args) {
new Boxer1(new Integer(4));
}
}
Whatis the result?
A. The value "4" is printed at the command line.
B. Compilation fails because of an error in line 5.C.Compilation fails because of an error in line 9.
D. A NullPointerException occurs at runtime.
E. A NumberFormatException occurs at runtime.
F. An IllegalStateException occurs at runtime.
Answer: D
Section: (none)
Explanation/Reference:Explanation:
QUESTION 185 Which two codefragments are most likely to cause a StackOverflowError? (Choose two.)
A. int []x = {1,2,3,4,5}; for(int y = 0; y < 6; y++)System.out.println(x[y]); B. static int[] x = {7,6,5,4}; static { x[1] = 8;x[4] = 3; }
C. for(int y = 10; y < 10; y++)doStuff(y);
D. void doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); } voiddoThree(int z) { doTwo(z); }
E. for(int x = 0; x < 1000000000; x++)doStuff(x);
F. void counter(int i) { counter(++i); }
Answer: DF
Section: (none)
Explanation/Reference:Explanation:
QUESTION 186 Given:
static void test() throws RuntimeException {
try {
System.out.print("test ");
throw new RuntimeException();
}
catch (Exception ex) { System.out.print("exception"); }
}
public static void main(String[] args) {
try { test(); }
catch (RuntimeException ex) { System.out.print("runtime"); }
System.out.print("end ");
}
Whatis the result?
A. test end B.Compilation fails.
C. test runtime end
D. test exception end
E. A Throwable is thrown by main at runtime.
Answer: D
Section: (none)
Explanation/Reference:Explanation:
QUESTION 187 Given:
public static void main(String[] args) {
Integer i = new Integer(1) + new Integer(2);
switch(i) {
case 3: System.out.println("three"); break;
default: System.out.println("other"); break;
}
}
Whatis the result?
A. three
B. other
C. An exception is thrown at runtime.
D. Compilation fails because of an error on line 12.E.Compilation fails because of an error on line 13. F. Compilation fails becauseof an error on line 15.
Answer: A
Section: (none)
Explanation/Reference:Explanation:
QUESTION 188 Given:
class Money {
private String country = "Canada";
public String getC() { return country; }
}
class Yen extends Money {
public String getC() { return super.country; }
}
public class Euro extends Money {
public String getC(int x) { return super.getC(); }
public static void main(String[] args) {
System.out.print(new Yen().getC() + " " + newEuro().getC());
}
}
Whatis the result?
A. Canada
B. null CanadaC. Canada null
D. Canada Canada
E. Compilation fails due to an error on line 26.F. Compilationfails due to an error on line 29.
Answer: E
Section: (none)
Explanation/Reference:Explanation:
QUESTION 189 Given:
class ClassA {}
class ClassBextends ClassA {} 13. class ClassC extends ClassA {} and:
ClassA p0 = new ClassA();
ClassB p1 = new ClassB();
ClassC p2 = new ClassC();
ClassA p3 = new ClassB();
ClassA p4 = new ClassC();
Whichthree are valid? (Choose three.)
A. p0 = p1; B. p1= p2; C. p2 = p4;
D. p2 = (ClassC)p1;
E. p1 = (ClassB)p3;
F. p2 = (ClassC)p4;
Answer: AEF
Section: (none)
Explanation/Reference:Explanation:
QUESTION 190 Which threestatements are true? (Choose three.)
A. A final method in class X can be abstract if and only if Xis abstract.
B. A protected method in class X can be overridden by anysubclass of X.
C. A private static method can be called only within otherstatic methods in class X.
D. A non-static public final method in class X can beoverridden in any subclass of X.
E. A public static method in class X can be called by a subclassof X without explicitly referencing theclass X.
F. A method with the same signature as a private final methodin class X can be implemented in asubclass of X.
G. A protected method in class X can be overridden by asubclass of X only if the subclass is in the samepackage as X.
Answer: BEF
Section: (none)
Explanation/Reference:Explanation:
QUESTION 191 Given:
interface A { void x(); }
class B implements A { public void x() {} public void y() {}}
class C extends B { public void x() {} }
And:
java.util.List<A> list = newjava.util.ArrayList<A>();
list.add(new B());
list.add(new C());
for (A a : list) {
a.x();
a.y();
}
Whatis the result?
A. The code runs with no output.
B. An exception is thrown at runtime.
C. Compilation fails because of an error in line 20.D.Compilation fails because of an error in line 21. E. Compilation fails becauseof an error in line 23. F. Compilation fails because of an error in line 25.
Answer: F
Section: (none)
Explanation/Reference:Explanation:
QUESTION192 Given:
package test;2.
class Target {
public String name = "hello";
}
Whatcan directly access and change the value of the variable name?
A. any class
B. only the Target class
C. any class in the test package
D. any class that extends Target
Answer: C
Section: (none)
Explanation/Reference:Explanation:
QUESTION 194
Ateam of programmers is involved in reviewing a proposed design for a newutility class. After some discussion, they realize that the current designallows other classes to access methods in the utility class that should beaccessible only to methods within the utility class itself. What design issuehas the team discovered?
A. Tight coupling
B. Low cohesion
C. High cohesion
D. Loose coupling
E. Weak encapsulation
F. Strong encapsulation
Answer: E
Section: (none)
Explanation/Reference:Explanation:
QUESTION 195 Given:
class Thingy { Meter m = new Meter(); }
class Component { void go() {System.out.print("c"); } }
class Meter extends Component { void go() {System.out.print("m"); } }
class DeluxeThingy extends Thingy {
public static void main(String[] args) {
DeluxeThingy dt = new DeluxeThingy();
dt.m.go();
Thingy t = new DeluxeThingy();
t.m.go();
}
}
Whichtwo are true? (Choose two.)
A. The output is mm.
B. The output is mc.
C. Component is-a Meter.
D. Component has-a Meter.
E. DeluxeThingy is-a Component.
F. DeluxeThingy has-a Component.
Answer: AF
Section: (none)
Explanation/Reference:Explanation:
QUESTION 196
Given:
10.interface Jumper { public void jump(); } ...
20.class Animal {} ...
class Dog extends Animal {
Tail tail; 32. } ...
class Beagle extends Dog implements Jumper{
public void jump() {}
} ...
class Cat implements Jumper{
public void jump() {}
}
Whichthree are true? (Choose three.)
A. Cat is-a Animal
B. Cat is-a JumperC. Dog is-a Animal
D. Dog is-a Jumper
E. Cat has-a Animal
F. Beagle has-a Tail
G. Beagle has-a Jumper
Answer: BCF
Section: (none)
QUESTION 198 Given a validDateFormat object named df, and
Date d = new Date(0L);
String ds = "December 15, 2004";
// insert code here What updates d's value with the daterepresented by ds?
A. 18. d = df.parse(ds);
B. 18. d = df.getDate(ds);
C. 18. try {
d = df.parse(ds);
} catch(ParseException e) { }; D. 18. try {
d = df.getDate(ds);
} catch(ParseException e) { };
Answer: C
Section: (none)
Explanation/Reference:Explanation:
QUESTION 199
Whichtwo scenarios are NOT safe to replace a StringBuffer object with aStringBuilder object? (Choose two.)
A. When using versions of Java technology earlier than 5.0.
B. When sharing a StringBuffer among multiple threads.
C. When using the java.io class StringBufferInputStream.
D. When you plan to reuse the StringBuffer to build more thanone string.
Answer: AB
Section: (none)
Explanation/Reference:Explanation:
QUESTION200 Given:
String test = "a1b2c3";
String[] tokens = test.split("d");
for(String s: tokens) System.out.print(s + " ");
Whatis the result?
A. a b c
B. 1 2 3
C. a1b2c3
D. a1 b2 c3
E. Compilation fails.
F. The code runs with no output.
G. An exception is thrown at runtime.
Answer: A
Section: (none)
Explanation/Reference:
QUESTION 201 Given:
public class TestString3 {
public static void main(String[] args) {
// insert code here
System.out.println(s);
}
}
Whichtwo 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");C.delete(0,3).replace(1,3,"24").delete(4,6);
D. StringBuffer s = new StringBuffer("123456789");
E. substring(3,6).delete(1,3).insert(1, "24");
F. StringBuilder s = newStringBuilder("123456789");G. substring(3,6).delete(1,2).insert(1,"24");
H. StringBuilder s = new StringBuilder("123456789");
I. delete(0,3).delete(1,3).delete(2,5).insert(1,"24");
Answer: BE
Section: (none)
Explanation/Reference:Explanation:
QUESTION 202 Given:
String test = "Test A. Test B. Test C.";
// insert code here
String[] result = test.split(regex);
Whichregular expression, inserted at line 12, correctly splits test into "TestA", "Test B", and "Test C"?
A. String regex = "";
B. String regex = " ";
C. String regex = ".*";
D. String regex = "s";
E. String regex = ".s*";
F. String regex = "w[ .] +";
Answer: E
Section: (none)
Explanation/Reference:Explanation:
QUESTION 203 Which statement istrue?
A. A class's finalize() method CANNOT be invoked explicitly.
B. super.finalize() is called implicitly by any overridingfinalize() method.
C. The finalize() method for a given object is called no morethan once by the garbage collector.
D. The order in which finalize() is called on two objects isbased on the order in which the two objectsbecame finalizable.
Answer: C
Section: (none)
Explanation/Reference:Explanation:
QUESTION 204 Given:
public class ItemTest {
private final int id;
publicItemTest(int id) { this.id = id; } 14. public void updateId(int newId) { id =newId; }
public static void main(String[] args) {
ItemTest fa = new ItemTest(42);
fa.updateId(69);
System.out.println(fa.id);
}
}
Whatis the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The attribute id in the ItemTest object remains unchanged.
D. The attribute id in the ItemTest object is modified to thenew value.
E. A new ItemTest object is created with the preferred value inthe id attribute.
Answer: A
Section: (none)
Explanation/Reference:Explanation:
QUESTION 205 Given:
interface DeclareStuff {
public static final int EASY = 3;
void doStuff(int t); }
public class TestDeclare implements DeclareStuff {
public static void main(String [] args) {
int x = 5;
new TestDeclare().doStuff(++x);
}
void doStuff(int s) {
s += EASY + ++s;
System.out.println("s " + s);
}
}
Whatis the result?
A.s 14 B. s 16 C. s 10
D. Compilation fails.
E. An exception is thrown at runtime.
Answer: D
Section: (none)
QUESTION 207 Given:
public class Commander {
public static void main(String[] args) {
String myProp = / insert code here /
System.out.println(myProp);
}
}and the commandline:
java-Dprop.custom=gobstopper Commander Which two, placed on line 13, will producethe output gobstopper? (Choose two.)
A. System.load("prop.custom");
B. System.getenv("prop.custom");
C. System.property("prop.custom");
D. System.getProperty("prop.custom");
E. System.getProperties().getProperty("prop.custom");
Answer: DE
Section: (none)
Explanation/Reference:Explanation:
QUESTION 208 Given:
interface DoStuff2 {
float getRange(int low, int high); }
interface DoMore {
float getAvg(int a, int b, int c); }
7.abstract class DoAbstract implements DoStuff2, DoMore { }
8.
class DoStuffimplements DoStuff2 { 10. public float getRange(int x, int y) { return 3.14f; }}
interface DoAll extends DoMore { 13. float getAvg(int a,int b, int c, int d); } What is the result?
A. The file will compile without error.
B. Compilation fails. Only line 7 contains an error.
C. Compilation fails. Only line 12 contains an error.
D. Compilation fails. Only line 13 contains an error.
E. Compilation fails. Only lines 7 and 12 contain errors.F.Compilation fails. Only lines 7 and 13 contain errors.
G.Compilation fails. Lines 7, 12, and 13 contain errors.
Answer: A
Section: (none)
Explanation/Reference:Explanation:
QUESTION 209 Given:
interface Fish { }
class Perch implements Fish { }
class Walleye extends Perch { }
class Bluegill { }
public class Fisherman {
public static void main(String[] args) {
Fish f = new Walleye();
Walleye w = new Walleye();
Bluegill b = new Bluegill();
if(f instanceof Perch) System.out.print("f-p ");
if(w instanceof Fish) System.out.print("w-f ");
if(b instanceof Fish) System.out.print("b-f ");
}
}
Whatis the result?
A. w-f
B. f-p w-f
C. w-f b-f
D. f-p w-f b-f
E. Compilation fails.
F. An exception is thrown at runtime.
Answer: B
Section: (none)
QUESTION 211 Given:
1.package com.company.application;
2.
public class MainClass {
public static void main(String[] args) {}
}
AndMainClass exists in the /apps/com/company/application directory. Assume theCLASSPATH environment variable is set to "." (current directory).Which two java commands entered at the command line will run MainClass? (Choosetwo.)
A. java MainClass if run from the /apps directory
B. java com.company.application.MainClass if run from the /appsdirectory
C. java -classpath /apps com.company.application.MainClass ifrun from any directory
D. java -classpath . MainClass if run from the/apps/com/company/application directory
E. java -classpath /apps/com/company/application:. MainClass ifrun from the /apps directory
F. java com.company.application.MainClass if run from the/apps/com/company/application directory
Answer: BC
Section: (none)
Explanation/Reference:Explanation:
QUESTION 212 Given:
import java.util.*;
public class Explorer2 {
public static void main(String[] args) {
TreeSet<Integer> s = new TreeSet<Integer>();
TreeSet<Integer> subs = new TreeSet<Integer>();
for(int i = 606; i < 613; i++)
if(i%2 == 0) s.add(i);
subs = (TreeSet)s.subSet(608, true, 611, true);
s.add(629);
System.out.println(s + " " + subs);
}
}
Whatis the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. [608, 610, 612, 629] [608, 610]
D. [608, 610, 612, 629] [608, 610, 629]E. [606, 608, 610, 612,629] [608, 610]
F.[606, 608, 610, 612, 629] [608, 610, 629]
Answer: E
Section: (none)
Explanation/Reference:Explanation:
QUESTION 213 Given that theelements of a PriorityQueue are ordered according to natural ordering, and:
import java.util.*;
public class GetInLine {
public static void main(String[] args) {
PriorityQueue<String> pq = newPriorityQueue<String>();
pq.add("banana");
pq.add("pear");
pq.add("apple");
System.out.println(pq.poll() + " " + pq.peek());
}
}
Whatis the result?
A. apple pear
B. banana pear
C. apple apple
D. apple banana
E. banana banana
Answer: D
Section: (none)
Explanation/Reference:Explanation:
QUESTION 214 Given apre-generics implementation of a method:
public static int sum(List list) {
int sum = 0;
for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
int i = ((Integer)iter.next()).intValue();
sum += i;
}
return sum;
}
Whatthree changes allow the class to be used with generics and avoid an uncheckedwarning? (Choose three.)
A. Remove line 14.
B. Replace line 14 with "int i = iter.next();".
C. Replace line 13 with "for (int i : intList) {".
D. Replace line 13 with "for (Iterator iter : intList){".
E. Replace the method declaration with"sum(List<int> intList)".
F. Replace the method declaration with"sum(List<Integer> intList)".
Answer: ACF
Section: (none)
Explanation/Reference:Explanation:
QUESTION 215 Given:
HashMap props = new HashMap();
props.put("key45", "some value");
props.put("key12", "some other value");
props.put("key39", "yet another value");
Set s = props.keySet();
// insert code here What, inserted at line 39, will sort thekeys in the props HashMap?
A. Arrays.sort(s);
B. s = new TreeSet(s);
C. Collections.sort(s);
D. s = new SortedSet(s);
Answer: B
Section: (none)
Explanation/Reference:Explanation:
QUESTION 216 Given:
public class Person {
private String name;
public Person(String name) {
this.name = name;
}
public boolean equals(Object o) {
if ( ! ( o instanceof Person) ) return false;
Person p = (Person) o;
return p.name.equals(this.name);
}
}
Whichstatement is true?
A. Compilation fails because the hashCode method is notoverridden.
B. A HashSet could contain multiple Person objects with thesame name.
C. All Person objects will have the same hash code because thehashCode method is not overridden.
D. If a HashSet contains more than one Person object withname="Fred", then removing another Person,also withname="Fred", will remove them all.
Answer: B
Section: (none)
Explanation/Reference:Explanation:
QUESTION 217 Given:
import java.util.*;
public class Hancock {
// insert code here
list.add("foo");
}
}
Whichtwo code fragments, inserted independently at line 5, will compile withoutwarnings? (Choose two.)
A. public void addStrings(List list) {
B. public void addStrings(List<String> list) {
C. public void addStrings(List<? super String> list) {
D. public void addStrings(List<? extends String> list) {
Answer: BC
Section: (none)
Explanation/Reference:Explanation:
QUESTION 218 Given:
public class Threads4 {
public static void main (String[] args) {
new Threads4().go();
}
public void go() {
Runnable r = new Runnable() {
public void run() {
System.out.print("foo");
}
};
Thread t = new Thread(r);
t.start();
t.start();
}
}
Whatis the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes normally and prints "foo".
D. The code executes normally, but nothing is printed.
Answer: B
Section: (none)
Explanation/Reference:Explanation:
QUESTION 219 Given:
public class TestOne {
public static void main (String[] args) throws Exception {
Thread.sleep(3000);
System.out.println("sleep");
}
} What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes normally and prints "sleep".
D. The code executes normally, but nothing is printed.
Answer: C
Section: (none)
Explanation/Reference:Explanation:
QUESTION 220 Given:
public class TestSeven extends Thread {
private static int x;
public synchronized void doThings() {
int current = x;
current++;
x = current;
}
public void run() {
doThings();
}
11.}
Whichstatement is true?
A. Compilation fails.
B. An exception is thrown at runtime.
C. Synchronizing the run() method would make the classthread-safe.
D. The data in variable "x" are protected fromconcurrent access problems.
E. Declaring the doThings() method as static would make theclass thread-safe.
F. Wrapping the statements within doThings() in asynchronized(new Object()) { } block would make theclass thread-safe.
Answer: E
Section: (none)
Explanation/Reference:Explanation:
QUESTION 221 Which two codefragments will execute the method doStuff() in a separate thread? (Choose two.)
A. new Thread() {
publicvoid run() { doStuff(); }
};
B. new Thread() {
publicvoid start() { doStuff(); }
};
C. new Thread() {
publicvoid start() { doStuff(); }
}.run();
D. new Thread() {
publicvoid run() { doStuff(); }
}.start();
E. new Thread(new Runnable() {public void run() { doStuff(); }
}).run();
F. new Thread(new Runnable() {public void run() { doStuff(); }
}).start();
Answer: DF
Section: (none)
Explanation/Reference:Explanation:
QUESTION 222 Given:
public static void main(String[] args) {
Object obj = new int[] { 1, 2, 3 };
int[] someArray = (int[])obj;
for (int i : someArray) System.out.print(i + " ");
}
Whatis the result?
A. 1 2 3
B. Compilation fails because of an error in line 12.C.Compilation fails because of an error in line 13.
D. Compilation fails because of an error in line 14.
E. A ClassCastException is thrown at runtime.
Answer: A
Section: (none)
Explanation/Reference:Explanation:
QUESTION 223 Given:
interface Data { public void load(); }
abstract class Info { public abstract void load(); }
Whichclass correctly uses the Data interface and Info class?
A. public class Employee extends Info implements Data { publicvoid load() { /do something/ }
}
B. public class Employee implements Info extends Data { publicvoid load() { /do something/ }
}
C. public class Employee extends Info implements Data { publicvoid load(){ /do something/ }public void Info.load(){ /do something/ }
}
D. public class Employee implements Info extends Data { publicvoid Data.load(){ /do something/ }public void load(){ /do something/ }
}
E. public class Employee implements Info extends Data { publicvoid load(){ /do something/ }public void Info.load(){ /do something/ }
}
F. public class Employee extends Info implements Data{publicvoid Data.load() { /do something/ }
publicvoid Info.load() { /do something/ }
}
Answer: A
Section: (none)
Explanation/Reference:Explanation:
QUESTION 224 Given:
public static void parse(String str) {
try {
float f = Float.parseFloat(str);
} catch (NumberFormatException nfe) {
f = 0;
} finally {
System.out.println(f);
}
}
public static void main(String[] args) {
parse("invalid");
}
Whatis the result?
A. 0.0
B. Compilation fails.
C. A ParseException is thrown by the parse method at runtime.
D. A NumberFormatException is thrown by the parse method atruntime.
Answer: B
Section: (none)
Explanation/Reference:Explanation:
QUESTION 225
Given 11. public interface Status {
/ insert code here / int MY_VALUE = 10;
}
Whichthree are valid on line 12? (Choose three.)
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected
Answer: ABD
Section: (none)
Explanation/Reference:Explanation:
QUESTION 226 Given:
interface TestA { String toString(); }
public class Test {
public static void main(String[] args) {
System.out.println(new TestA() {
public String toString() { return "test"; }
});
}
}
Whatis the result?
A. test B. null
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 1.E.Compilation fails because of an error in line 4. F. Compilation fails becauseof an error in line 5.
Answer: A
Section: (none)
Explanation/Reference:Explanation:
QUESTION 227 Given:
11.public interface A { public void m1(); }
12.
class B implements A { }
class C implements A { public void m1() { } }
class D implements A { public void m1(int x) { } }
abstract class E implements A { }
abstract class Fimplements A { public void m1() { } } 18. abstract class G implements A {public void m1(int x) { } }
Whatis the result?
A. Compilation succeeds.
B. Exactly one class does NOT compile.
C. Exactly two classes do NOT compile.
D. Exactly four classes do NOT compile.
E. Exactly three classes do NOT compile.
Answer: C
Section: (none)
Explanation/Reference:Explanation:
QUESTION 228 Given:
abstract class C1 {
public C1() { System.out.print(1); }
}
class C2 extends C1 {
public C2() { System.out.print(2); }
}
class C3 extends C2 {
public C3() { System.out.println(3); }
}
public class Ctest {
public static void main(String[] a) { new C3(); }
}
Whatis the result?
A. 3
B. 23C. 32
D. 123
E. 321
F. Compilation fails.
G. An exception is thrown at runtime.
Answer: D
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4550/viewspace-2815692/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SOLIDWORKS認證考試常見問題解答Solid
- SOLIDWORKS認證考試流程Solid
- SOLIDWORKS官方認證考試Solid
- HarmonyOS Connect認證測試
- MySQL OCP 8.0 認證1Z0-809考試題庫MySql
- MySQL 8.0 OCP 1Z0-908認證考試題庫1MySql
- 認證授權問題概覽
- H3CNE認證(題庫)
- 福祿克的驗證測試和認證測試的區別
- CISSP認證考試指南(第7版)
- 使用DSX-5000 ch網線認證測試儀LinkWareLive記錄佈線認證
- 有關Laravel Passport認證的問題LaravelPassport
- 軟體測試的驗證和確認
- 計劃做點事情-可信認證考試
- 你是真的程式猿嗎—>測試認證
- 同屏器CE認證測試標準
- Laravel 單元測試認證使用者Laravel
- Java面試指北!13個認證授權常見面試題/知識點總結!| JavaGuideJava面試題GUIIDE
- 認證授權方案之JwtBearer認證JWT
- HTTP認證之基本認證——Basic(一)HTTP
- HTTP認證之基本認證——Basic(二)HTTP
- HTTP認證之摘要認證——Digest(一)HTTP
- 10.05.25主題--CMMI認證實施案例分析
- 無線上網認證之Portal認證
- WHQL認證2019年3月 認證流程
- Oracle Goldengate(ogg) 12c認證考試流程OracleGo
- 職業認證---系統整合工程師考試工程師
- 2020年C證(安全員)考試題庫及C證(安全員)新版試題
- 增強版實名認證介面-Java身份證實名認證介面程式碼-身份認證Java
- 解決 Laravel JWT 多表認證時獲取不到當前認證使用者的問題LaravelJWT
- 本地認證
- CB認證
- Passport 認證Passport
- 全網最全:華為鴻蒙高階認證資料考試習題彙總鴻蒙
- Oracle 19c OCP 1Z0-082認證考試題庫(7-12)Oracle
- Oracle 19c OCP 1Z0-082認證考試題庫(13-18)Oracle
- Oracle 19c OCP 1Z0-082認證考試題庫(19-23)Oracle
- Oracle 19c OCP 1Z0-082認證考試題庫(24-29)Oracle