별의 공부 블로그 🧑🏻‍💻
728x90
728x170

QUESTION 51

Given classes defined in two different files:

 

package packageA;

public class Message { String getText() { return "text";

}

}

 

And:

 

package packageB;

public class XMLMessage extends packageA.Message { String getText() {

return "<msg>text</msg>";

}

 

public static void main(String[] args) { System.out.println(new XMLMessage().getText());

}

}

 

What is the result of executing XMLMessage.main?

 

A.    text

B.    Compilation fails.

C.    <msg>text</msg>

D.    An exception is thrown at runtime.

 

Correct Answer: C Section: All Explanation

 

Explanation/Reference:

 

 

QUESTION 52

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 ");

}

}

 

What is 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.

 

Correct Answer: B Section: All Explanation

 

Explanation/Reference:

 

 

QUESTION 53

Given:

 

package com.company.application;

 

public class MainClass {

public static void main(String[] args) {

}

}

 

and MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH environment variable is set to "." (current directory). Which two java commands entered at the command line will run MainClass? (Choose two.)

 

A.    java MainClass if run from the /apps directory

B.    java com.company.application.MainClass if run from the /apps directory

C.    java -classpath /apps com.company.application.MainClass if run from any directory

D.    java -classpath . MainClass if run from the /apps/com/company/application directory

E.    java -classpath /apps/com/company/application:. MainClass if run from the /apps directory

F.    java com.company.application.MainClass if run from the /apps/com/company/application directory

 

Correct Answer: BC Section: All Explanation

 

Explanation/Reference:

 

 

QUESTION 54

Given

 

class Foo {

static void alpha() {

/* more code here */

}

 

void beta() {

/* more code here */

}

}

 

Which two statements are true? (Choose two.)

 

A.    Foo.beta() is a valid invocation of beta().

B.    Foo.alpha() is a valid invocation of alpha().

C.    Method beta() can directly call method alpha().

D.    Method alpha() can directly call method beta().

 

Correct Answer: BC Section: All Explanation

 

Explanation/Reference:

 

 

QUESTION 55

Given:

 

public class TestSeven extends Thread {

private static int x;

public synchronized void doThings() {

int current = x; current++;

x = current;

}

public void run() { doThings();

}

}

 

Which statement is true?

 

A.    Compilation fails.

B.    An exception is thrown at runtime.

C.    Synchronizing the run() method would make the class thread-safe.

D.    The data in variable "x" are protected from concurrent access problems.

E.    Declaring the doThings() method as static would make the class thread-safe.

F.    Wrapping the statements within doThings() in a synchronized(new Object()) { } block would make the class thread-safe.

 

Correct Answer: E Section: All Explanation

 

Explanation/Reference:

 

 

QUESTION 56

Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following:

 

import java.io.*;

public class Maker {

public static void main(String[] args) { File dir = new File("dir");

File f = new File(dir, "f");

}

}

 

Which statement is true?

 

A.    Compilation fails.

B.    Nothing is added to the file system.

C.    Only a new file is created on the file system.

D.    Only a new directory is created on the file system.

E.    Both a new file and a new directory are created on the file system.

 

Correct Answer: B Section: All Explanation

 

Explanation/Reference:

 

 

QUESTION 57

Given:

 

NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(4); nf.setMinimumFractionDigits(2);

String a = nf.format(3.1415926); String b = nf.format(2);

 

Which two statements are true about the result if the default locale is Locale.US? (Choose two.)

 

A.    The value of b is 2.

B.    The value of a is 3.14.

C.    The value of b is 2.00.

D.    The value of a is 3.141.

E.    The value of a is 3.1415.

F.    The value of a is 3.1416.

G.   The value of b is 2.0000.

 

Correct Answer: CF


 

Section: All Explanation

 

Explanation/Reference:

 

 

QUESTION 58

Which three statements concerning the use of the java.io.Serializable interface are true? (Choose three.)

 

A.    Objects from classes that use aggregation cannot be serialized.

B.    An object serialized on one JVM can be successfully deserialized on a different JVM.

C.    The values in fields with the volatile modifier will NOT survive serialization and deserialization.

D.    The values in fields with the transient modifier will NOT survive serialization and deserialization.

E.    It is legal to serialize an object of a type that has a supertype that does NOT implement java.io.Serializable.

 

Correct Answer: BDE Section: All Explanation

 

Explanation/Reference:

 

 

QUESTION 59

Given:

 

12.  String csv = "Sue,5,true,3";

13.  Scanner scanner = new Scanner( csv );

14.  scanner.useDelimiter(",");

15.  int age = scanner.nextInt();

 

What is the result?

 

A.    Compilation fails.

B.    After line 15, the value of age is 5.

C.    After line 15, the value of age is 3.

D.    An exception is thrown at runtime.

 

Correct Answer: D Section: All Explanation

 

Explanation/Reference:

Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Unknown Source)

at  java.util.Scanner.next(Unknown  Source) at java.util.Scanner.nextInt(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at Breaker.main(Breaker.java:8)

 

 

QUESTION 60

Given:

 

11.  String test = "a1b2c3";

12.  String[] tokens = test.split("\\d");

13.  for(String s: tokens) System.out.print(s + " ");

 

What is 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.

 

Correct Answer: A Section: All Explanation

 

Explanation/Reference:

 

 

 

 


Source from : Oracle.Exactexams.1z0-851.v2013-11-27.by.SomeBody ().pdf

728x90
그리드형(광고전용)

'Certificate > OCAJP' 카테고리의 다른 글

[1Z0-851D] Question 31~40  (0) 2017.08.13
[1Z0-851D] Question 21~30  (0) 2017.08.13
[1Z0-851D] Question 11~20  (0) 2017.08.13
[1Z0-851D] Question 01~10  (0) 2017.08.13
[1Z0-851C] Question 41~50  (0) 2017.08.12
[1Z0-851C] Question 31~40  (0) 2017.08.12
[1Z0-851C] Question 21~30  (0) 2017.08.12
[1Z0-851C] Question 11~20  (0) 2017.08.12
⚠️AdBlock이 감지되었습니다. 원할한 페이지 표시를 위해 AdBlock을 꺼주세요.⚠️
starrykss
starrykss
별의 공부 블로그 🧑🏻‍💻


📖 Contents 📖