0% found this document useful (0 votes)
74 views12 pages

The Leading Company Provides Valid Exam Cram PDF & Dumps PDF Materials

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 12

CramPDF

http://www.crampdf.com
The leading company provides valid exam cram PDF & dumps PDF materials
IT Certification Guaranteed, The Easy Way!

Exam : 1z0-803

Title : Java SE 7 Programmer I

Vendor : Oracle

Version : DEMO

1
IT Certification Guaranteed, The Easy Way!

NO.1 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 blocks fall 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.

NO.2 Given the code fragment

Which code fragments, inserted independently, enable the code compile?


A. t.fvar = 200;
B. cvar = 400;
C. fvar = 200; cvar = 400;
D. this.fvar = 200; this.cvar = 400;

2
IT Certification Guaranteed, The Easy Way!

E. t.fvar = 200; Test2.cvar = 400;


F. this.fvar = 200; Test2.cvar = 400;
Answer: B

NO.3 Given:
public class X {
static int i;
int j;
public static void main(String[] args) {
X x1 = new X();
X x2 = new X();
x1.i = 3;
x1.j = 4;
x2.i = 5;
x2.j = 6;
System.out.println(
x1.i + " "+
x1.j + " "+
x2.i + " "+
x2.j);
} } What is the result?
A. 3 4 5 6
B. 3 4 3 6
C. 5 4 5 6
D. 3 6 4 6
Answer: C

NO.4 Given:

What is the result?


A. 2 1
B. 2 1 0
C. null
D. an infinite loop
E. compilation fails

3
IT Certification Guaranteed, The Easy Way!

Answer: E
Explanation:
The line while (--ii); will cause the compilation to fail. ii is not a boolean value.
A correct line would be while (--ii>0);

NO.5 Given the code fragment:

What is the result?


A. 3 false 1
B. 2 true 3
C. 2 false 3
D. 3 true 1
E. 3 false 3
F. 2 true 1
G. 2 false 1
Answer: D
Explanation:
The length of the element with index 0, {0, 1, 2}, is 3. Output: 3 The element with index 1, {3, 4, 5, 6},
is of type array. Output: true The element with index 0, {0, 1, 2} has the element with index 1: 1.
Output: 1

NO.6 Given:

What is the result?

4
IT Certification Guaranteed, The Easy Way!

A. 0 Done
B. First Exception Done
C. Second Exception
D. Done Third Exception
E. Third Exception
Answer: E

NO.7 Given the code fragment:

A. Super Sub Sub


B. Contract Contract Super
C. Compilation fails at line n1
D. Compilation fails at line n2
Answer: D

NO.8 Given:

Which two are possible outputs?

5
IT Certification Guaranteed, The Easy Way!

A. Option A
B. Option B
C. Option C
D. Option D
Answer: A,D
Explanation:
The first println statement, System.out.println("Before if clause");, will always run.
If Math.Random() > 0.5 then there is an exception. The exception message is displayed and the
program terminates.
If Math.Random() > 0.5 is false, then the second println statement runs as well.

NO.9 Which three are advantages of the Java exception mechanism?


A. Improves the program structure because the error handling code is separated from the normal
program function
B. Provides a set of standard exceptions that covers all the possible errors
C. Improves the program structure because the programmer can choose where to handle exceptions
D. Improves the program structure because exceptions must be handled in the method in which they
occurred
E. allows the creation of new exceptions that are tailored to the particular program being
Answer: A,C,E
Explanation:
A: The error handling is separated from the normal program logic.
C: You have some choice where to handle the exceptions.
E: You can create your own exceptions.

NO.10 Given the code fragment:

6
IT Certification Guaranteed, The Easy Way!

What is the result?


A. 10 8 6 4 2 0
B. 10 8 6 4 2
C. AnArithmeticException is thrown at runtime
D. The program goes into an infinite loop outputting: 10 8 6 4 2 0. . .
E. Compilation fails
Answer: A

NO.11 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";
c.model = 1200;
return c;
}
public static void bake2(Cake c) {
c.flavor = "Chocolate";
c.model = 1230;
return;
}}
What is the result?
A. 0 unknown 0 unknown
B. 1200 Strawberry 1200 Strawberry
C. 1200 Strawberry 1230 Chocolate
D. Compilation fails
Answer: C

7
IT Certification Guaranteed, The Easy Way!

Explanation:
1200 Strawberry
1230 Chocolate

NO.12 Given:

What is the result?

A. Option A
B. Option B
C. Option C
D. Option D
Answer: C

NO.13 Given the code fragment:

8
IT Certification Guaranteed, The Easy Way!

What values of x, y, z will produce the following result?


1234
1234
1234
1234
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 Y must be set 3.
X is for the outmost loop. Should print 2 lines of. So X should be 2.

NO.14 Given: What is the result?

A. true true
B. true false
C. false true

9
IT Certification Guaranteed, The Easy Way!

D. false false
E. Compilation fails
Answer: E

NO.15 View the exhibit:


public class Student {
public String name = "";
public int age = 0;
public String major = "Undeclared";
public boolean fulltime = true;
public void display() {
System.out.println("Name: " + name + " Major: " + major); }
public boolean isFullTime() {
return fulltime;
}
}
Given:
Public class TestStudent {
public static void main(String[] args) {
Student bob = new Student ();
bob.name = "Bob";
bob.age = 18;
bob.year = 1982;
}
}
What is the result?
A. year is set to 1982.
B. bob.year is set to 1982
C. A runtime error is generated.
D. A compile time error is generated.
Answer: D

NO.16 Given:
public class MyClass { public static void main(String[] args) { while (int ii = 0; ii < 2) { ii++;
System.out.println("ii = " + ii); } }
}
What is the result?
A. ii = 1 ii = 2
B. Compilation fails
C. The program prints nothing
D. The program goes into an infinite loop with no output
E. The program goes to an infinite loop outputting: ii = 1 ii = 1

10
IT Certification Guaranteed, The Easy Way!

Answer: B
Explanation:
The while statement is incorrect. It has the syntax of a for statement.
The while statement continually executes a block of statements while a particular condition is true.
Its syntax can be expressed as:
while (expression) {
statement(s)
}
The while statement evaluates expression, which must return a boolean value. If the expression
evaluates to true, the while statement executes the statement(s) in the while block. The while
statement continues testing the expression and executing its block until the expression evaluates
to false.
Reference: The while and do-while Statements

11

You might also like