Sun.RealExamQuestions.310-065.Oracle.1Z0-851.v2012-01-28.by.Carlos.239q
Number: 1Z0-851 Passing Score: 610 Time Limit: 150 min File Version: 2012-01-28
Sun.RealExamQuestions.310-065.Oracle.1Z0-851.v2012-01-28.by.Carlos.239q
Exam : Sun 310-065 / Oracle 1Z0-851
Version : 2012-01-28
By Carlos - Brazil
Questions : 239 9 Exams (from A - I)
This file is based on Sun RealExamQuestions 310-065 v2011-11-08 by Stephen 306q.vce (http:// www.examcollection.com/sun/Sun.RealExamQuestions.310-065.v2011-11-08.by.Stephen.306q.vce. file.html). See the comments on its page for more infos.
Changes made from original file: - Removed duplicated questions. - Many answers were tested and better explained. - Removed "Exam J" because it had only drag and drop questions and other questions that had drag and drop (see posts from "Certification Forum Moderator - Brandye Barrington" on https:// forums.oracle.com/forums/thread.jspa?messageID=9640688&tstart=0#9640688)
----------------
Exam I
QUESTION 1 Given:
1. public class Pass2 {
2. public void main(String[] args) {
3. int x = 6;
4. Pass2 p = new Pass2();
5. p.doStuff(x);
6. System.out.print(" main x = " + x);
7. }
9. void doStuff(int x) {
10. System.out.print(" doStuff x = " + x++); 11. } 12.}
And the command-line invocations:
javac Pass2.java java Pass2 5
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuff x = 6 main x = 6 D. doStuff x = 6 main x = 7
E. doStuff x = 7 main x = 6
F. doStuff x = 7 main x = 7
Correct Answer: B
Explanation/Reference:
Exception in thread "main" java.lang.NoSuchMethodError: main
On line 2, the main method should be static
QUESTION 2 Given:
1. interface DeclareStuff {
2. public static final int EASY = 3;
4. void doStuff(int t);
5. }
7. public class TestDeclare implements DeclareStuff {
8. public static void main(String[] args) {
9. int x = 5;
10. new TestDeclare().doStuff(++x);
11. }
12.
13. void doStuff(int s) {
14. s += EASY + ++s;
15. System.out.println("s " + s);
16. }
17.}
What is the result?
A. s 14
B. s 16
C. s 10
D. Compilation fails.
E. An exception is thrown at runtime.
Correct Answer: D
Explanation/Reference: Cannot reduce the visibility of the inherited method from DeclareStuff
Interface methods are public so doStuff is public in DeclareStuff interface. doStuff is package-private in TestDeclare class and this visibility change is not allowed.
QUESTION 3 A class games.cards.Poker is correctly defined in the jar file Poker.jar. A user wants to execute the main method of Poker on a UNIX system using the command:
java games.cards.Poker
What allows the user to do this?
A. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java
B. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/*.jar
C. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/Poker.jar
D. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java
E. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java/*.jar
F. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java/Poker.
jar
Correct Answer: C
QUESTION 4 Given a correctly compiled class whose source code is:
1. package com.sun.sjcp;
3. public class Commander {
4. public static void main(String[] args) {
5. // more code here
6. }
7. }
Assume that the class file is located in /foo/com/sun/sjcp/, the current directory is /foo/, and that the classpath contains "." (current directory). Which command line correctly runs Commander?
A. java Commander
B. java com.sun.sjcp.Commander
C. java com/sun/sjcp/Commander
D. java -cp com.sun.sjcp Commander
E. java -cp com/sun/sjcp Commander
Correct Answer: B
QUESTION 5 Given:
interface DoStuff2 {
float getRange(int low, int high);
}
interface DoMore {
float getAvg(int a, int b, int c);
}
abstract class DoAbstract implements DoStuff2, DoMore {
}
class DoStuff implements DoStuff2 {
public float getRange(int x, int y) {
return 3.14f;
}
}
interface DoAll extends DoMore {
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.
Correct Answer: A
Also Read :
- SCJP / OCJP dumps 1