Monday, July 7, 2014

1Z0-803: Java SE 7 Programmer I Certification Exam Dumps: Real Exam Questions



QUESTION NO: 1
Given the code fragment:
String valid = "true";
if (valid) System.out.println (“valid”);
else system.out.println ("not valid");
What is the result?
A. Valid
B. not valid
C. Compilation fails
D. An IllegalArgumentException is thrown at run time
Answer: C

QUESTION NO: 2
Given:
public class DoCompare1 {
public static void main(String[] args) {
String[] table = {"aa", "bb", "cc"};
for (String ss: table) {
int ii = 0;
while (ii < table.length) {
System.out.println(ss + ", " + ii);
ii++;
}
}
How many times is 2 printed as a part of the output?
A. Zero
B. Once
C. Twice
D. Thrice
E. Compilation fails.
Answer: D

QUESTION NO: 3
Given:
public class x{
public static void main (string [] args){
String theString = "Hello World";
System.out.println(theString.charAt(11));
}
}
What is the result?
A. There is no output
B. d is output
C. A StringIndexOutOfBoundsException is thrown at runtime
D. An ArrayIndexOutOfBoundsException is thrown at runtime
E. A NullPointException is thrown at runtime
F. A StringArrayIndexOutOfBoundsException is thrown at runtime
Answer: C

QUESTION NO: 4
Given the code fragment:
String h1 = "Bob";
String h2 = new String ("Bob");
What is the best way to test that the values of h1 and h2 are the same?
A. if (h1 == h2)
B. if (h1.equals(h2))
C. if (h1 = = h2)
D. if (h1.same(h2))
Answer: B

QUESTION NO: 5
Given:
class X {}
class Y {Y () {}}
class Z {z(int i ) {} }
Which class has a default constructor?
A. X only
B. Y only
C. Z only
D. X and Y
E. Y and Z
F. X and Z
G. X, Y and Z
Answer: F

QUESTION NO: 6
Given the fragment:
int [] array = {1, 2, 3, 4, 5};
System.arraycopy (array, 2, array, 1, 2);
System.out.print (array [1]);
System.out.print (array[4]);
What is the result?
A. 14
B. 15
C. 24
D. 25
E. 34
F. 35
Answer: F

QUESTION NO: 7
Given:
public class MyFor3 {
public static void main(String [] args) {
int [] xx = null;
System.out.println(xx);
}
}
What is the result?
A. null
B. compilation fails
C. Java.lang.NullPointerException
D. 0
Answer: A

QUESTION NO: 8
Given:
public class ScopeTest1 {
public static void main(String[] args) {
doStuff(); // line x1
int x1 = x2; // line x2
int x2 = j; // line x3
}
static void doStuff() {
System.out.println(j); // line x4
}
static int j;
}
Which line causes a compilation error?
A. line x1
B. line x2
C. line x3
D. line x4
Answer: B

QUESTION NO: 9
Which declaration initializes a boolean variable?
A. boolean h = 1;
B. boolean k = 0;
C. boolean m = null;
D. boolean j = (1 < 5) ;

Answer: D

QUESTION NO: 10
You are writing a method that is declared not to return a value. Which two are permitted in the
method body?
A. omission of the return statement
B. return null;
C. return void;
D. return;

Answer: A,D

I hope you must have find these questions very helpful. If you want to get complete set of real exam questions and their answer please visit our FAQ's section to know more.