Proper study guides for 1Z0-803 Java SE 7 Programmer I certified begins with 1z0 803 practice test preparation products which designed to deliver the java se 7 programmer i 1z0 803 by making you pass the 1Z0-803 test at your first time. Try the free 1z0 803 dumps right now.
Check 1Z0-803 free dumps before getting the full version:
NEW QUESTION 1
Given the code fragment:
interface SampleClosable {
public void close () throws java.io.IOException;
}
Which three implementations are valid?
- A. Option A
- B. Option B
- C. Option C
- D. Option D
- E. Option E
Answer: ACE
Explanation: A: Throwing the same exception is fine.
C: Using a subclass of java.io.IOException (here java.io.FileNotFoundException) is fine E: Not using a throw clause is fine.
NEW QUESTION 2
Given:
What is the result?
- A. Null
- B. Compilation fails
- C. An exception is thrown at runtime
Answer: C
NEW QUESTION 3
Given the code fragment:
What values ofx,y,zwill produce the following result?
1 2 3 4
1 2 3 4
1 2 3 4
----
1 2 3 4
----
- A. X = 4, Y = 3, Z= 2
- B. X = 3, Y = 2, Z = 3
- C. X = 2, Y = 3, Z = 3
- D. X = 4, Y = 2, Z = 3
- E. X = 2, Y = 3, Z = 4
Answer: E
Explanation: Z is for the innermost loop. Should print 1 2 3 4. So Z must be 4.
Y is for the middle loop. Should print three lines of 1 2 3 4. So Ymust be set 3. X is for the outmost loop. Should print 2 lines of. So X should be 2.
NEW QUESTION 4
Given:
Which code fragment, when inserted at line 14, enables the code to print Mike Found?
- A. int f = ps.indexOf {new patient (“Mike”)};
- B. int f = ps.indexOf (patient(“Mike”));
- C. patient p = new Patient (“Mike”); int f = pas.indexOf(P)
- D. int f = ps.indexOf(p2);
Answer: C
NEW QUESTION 5
Given:
class Cake { int model; String flavor; Cake() { model = 0;
flavor = "Unknown";
}
}
public class Test {
public static void main(String[] args) { Cake c = new Cake();
bake1(c);
System.out.println(c.model + " " + c.flavor); bake2(c);
System.out.println(c.model + " " + c.flavor);
}
public static Cake bake1(Cake c) { c.flavor = "Strawberry";
- A. c.model = 1200; return c;}public static void bake2(Cake c) {c.flavor = "Chocolate"; c.model = 1230; return;}}What is the result?
- B. 0 unknown0 unknown
- C. 1200 Strawberry1200 Strawberry
- D. 1200 Strawberry1230 Chocolate
- E. Compilation fails
Answer: C
Explanation: 1200 Strawberry
1230 Chocolate
NEW QUESTION 6
Which statement will empty the contents of aStringBuilder variable named sb?
- A. sb.deleteAll();
- B. sb.delete(0, sb.size());
- C. sb.delete(0, sb.length());
- D. sb.removeAll();
Answer: C
NEW QUESTION 7
Given:
What is the result?
- A. Shining Sun Shining Sun Shining Sun
- B. Shining Sun Twinkling Star Shining Sun
- C. Compilation fails
- D. A ClassCastException is thrown at runtime
Answer: D
NEW QUESTION 8
Given the code fragment?
public class Test {
public static void main(String[]args) { Test t = new Test();
int[] arr = new int[10]; arr = t.subArray(arr,0,2);
}
// insert code here
}
Which method can be inserted at line // insert code here to enable the code to compile?
- A. public int[] subArray(int[] src, int start, int end) { return src;}
- B. public int subArray(int src, int start, int end) { return src;}
- C. public int[] subArray(int src, int start, int end) { return src;}
- D. public int subArray(int[] src, int start, int end) { return src;}
Answer: A
NEW QUESTION 9
Given:
What is the result?
- A. Compilation fails
- B. An exception is thrown at runtime
- C. There is no result because this is not correct way to determine the hash code
- D. Hash is: 111111, 44444444, 999999999
Answer: A
Explanation: The compilation fails as SampleClassA and SampleClassB cannot overrideSampleClass because the return type of SampleClass is int, while the return type of SampleClassA and SampleClassB is long.
Note: If all three classes had the same return type the output would be: Hash is : 111111, 44444444, 999999999
NEW QUESTION 10
Given the code fragment:
public class Test {
static String[][] arr =new String[3][]; private static void doPrint() {
//insert code here
}
public static void main(String[] args) { String[] class1 = {"A","B","C"};
String[] class2 = {"L","M","N","O"}; String[] class3 = {"I","J"};
arr[0] = class1; arr[1] = class2; arr[2] = class3; Test.doPrint();
}
}
Which code fragment, when inserted at line //insert code here, enables the code to print COJ?
- A. int i = 0;for (String[] sub: arr) { int j = sub.length -1; for (String str: sub) {System.out.println(str[j]); i++;}}
- B. private static void doPrint() { for (int i = 0;i < arr.length;i++) { int j = arr[i].length-1; System.out.print(arr[i][j]);}}
- C. int i = 0;for (String[] sub: arr[][]) { int j = sub.length; System.out.print(arr[i][j]); i++;}
- D. for (int i = 0;i < arr.length-1;i++) { int j = arr[i].length-1;System.out.print(arr[i][j]); i++;}
Answer: B
Explanation: Incorrect:
not A: The following line causes a compile error: System.out.println(str[j]);
Not C: Compile erro line: for (String[] sub: arr[][]) not D: Output: C
NEW QUESTION 11
Given:
What is the result?
- A. They match They really match
- B. They really match
- C. They match
- D. Nothing Prints
- E. They reallymatch They really match
Answer: B
Explanation: The strings are not the same objects so the == comparison fails. See note #1 below. As the value of the strings are the same equals is true. The equals method compares values for equality.
Note: #1 ==
Compares references, not values. The use of == with object references is generally limited to the following:
Comparing to see if a reference is null.
Comparing two enum values. This works because there is only one object for each enum constant.
You want to knowif two references are to the same object.
NEW QUESTION 12
Given:
public class SampleClass {
public static void main(String[] args) {
AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new SampleClass();
sc = asc;
System.out.println("sc: " + sc.getClass()); System.out.println("asc: " + asc.getClass());
}}
class AnotherSampleClass extends SampleClass {
}
What is the result?
- A. sc: class Objectasc: class AnotherSampleClass
- B. sc: class SampleClassasc: class AnotherSampleClass
- C. sc: class AnotherSampleClass asc: class SampleClass
- D. sc: class AnotherSampleClassasc: class AnotherSampleClass
Answer: D
NEW QUESTION 13
Given:
Which statement, when inserted into line 5, is valid change?
- A. asc = sc;
- B. sc = asc;
- C. asc = (object) sc;
- D. asc = sc.clone ()
Answer: B
Explanation: Works fine.
NEW QUESTION 14
Given the code fragment:
What is the result?
- A. 22
- B. 12
- C. 32
- D. 33
Answer: A
Explanation: Variable b is set to 4.
Variableb is decreased to 3.
Variable b is decreased to 2 and then printed. Output: 2 Variable b is printed. Output: 2
NEW QUESTION 15
Given the following code fragment:
What is the result if the integer value is 33?
- A. The fox jump lazy …
- B. The fox lazy …
- C. Quick fox over lazy …
- D. Quick fox the ….
Answer: B
Explanation: 33 is greater than 0.
33 is not equal to 0. the is printed.
33 is greater than 30 fox is printed
33 is greater then 10 (the two else if are skipped) lazy is printed
finally … is printed.
NEW QUESTION 16
Given the code fragment:
What is the result?
- A. Found Red
- B. Found Red Found Blue
- C. Found Red Found Blue Found White
- D. Found Red Found Blue Found White Found Default
Answer: B
Explanation: As there is no break statement after the case "Red" statement the case Blue statement will run as well.
Note: The body of a switch statement is known as a switch block. A statement in the switch block can be labeled with one or more case or default labels. The switch statement evaluates its expression, then executes all statements that follow the matching case label.
Each break statement terminates the enclosing switch statement. Control flow continues with the first statement following the switch block. The break statements are necessary because without them, statements in switch blocksfall through:All statements after the matching case label are executed in sequence, regardless of the expression of subsequent
case labels, until a break statement is encountered.
NEW QUESTION 17
Given:
public class Equal {
public static void main(String[] args) { String str1 = "Java";
String[] str2 = {"J","a","v","a"}; String str3 = "";
for (String str : str2) { str3 = str3+str;
}
boolean b1 = (str1 == str3); boolean b2 = (str1.equals(str3)); System.out.print(b1+", "+b2);
}
What is the result?
- A. true, false
- B. false, true
- C. true, true
- D. false, false
Answer: B
Explanation: == strict equality. equals compare state, not identity.
NEW QUESTION 18
Given:
public class Natural { private int i;
void disp() { while (i <= 5) {
for (int i=1; i <=5;) { System.out.print(i + " "); i++;
} i++;
}
}
public static void main(String[] args) { new Natural().disp();
}
}
What is the result?
- A. Prints 1 2 3 4 5 once
- B. Prints 1 3 5 once
- C. Prints 1 2 3 4 5 five times
- D. Prints1 2 3 4 5 six times
- E. Compilation fails
Answer: D
Explanation: 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
Recommend!! Get the Full 1Z0-803 dumps in VCE and PDF From Surepassexam, Welcome to Download: https://www.surepassexam.com/1Z0-803-exam-dumps.html (New 216 Q&As Version)