Info For 1Z0-803 Exam 100% Pass: PassLeader provides you with the newest 1Z0-803 169q exam questions updated in recent days to prepare your 1Z0-803 certification exams. Our best 1Z0-803 169q exam dumps will offer you the newest questions and answers with premium VCE and PDF format to download. And PassLeader also offer you the latest free version VCE Player!
Vendor: Oracle
Exam Code: 1Z0-803
Exam Name: Java SE 7 Programmer I
QUESTION 61
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 62
Given:
public class Main {
public static void main (String[] args) {
doSomething();
}
private static void doSomething() {
doSomeThingElse();
}
private static void doSomeThingElse() {
throw new Exception();
}
}
Which approach ensures that the class can be compiled and run?
A. Put the throw new Exception() statement in the try block of try ?catch
B. Put the doSomethingElse() method in the try block of a try ?catch
C. Put the doSomething() method in the try block of a try ?catch
D. Put the doSomething() method and the doSomethingElse() method in the try block of a try ?catch
Answer: A
QUESTION 63
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 64
Given:
class Overloading {
void x (int i) {
System.out.println(“one”);
}
void x (String s) {
System.out.println(“two”);
}
void x (double d) {
System.out.println(“three”);
}
public static void main(String[] args) {
new Overloading().x (4.0);
}
}
What is the result?
A. One
B. Two
C. Three
D. Compilation fails
Answer: C
QUESTION 65
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 66
Given:
public class Basic {
private static int letter;
public static int getLetter();
public static void Main(String[] args) {
System.out.println(getLetter());
}
}
Why will the code not compile?
A. A static field cannot be private.
B. The getLetter method has no body.
C. There is no setletter method.
D. The letter field is uninitialized.
E. It contains a method named Main instead of ma
Answer: B
QUESTION 67
Given:
public class Circle {
double radius;
public double area:
public Circle (double r) { radius = r;}
public double getRadius() {return radius;}
public void setRadius(double r) { radius = r;}
public double getArea() { return /* ??? */;}
}
class App {
public static void main(String[] args) {
Circle c1 = new Circle(17.4);
c1.area = Math.PI * c1.getRadius() * c1.getRadius();
}
}
This class is poorly encapsulated. You need to change the circle class to compute and return the area instead. What three modifications are necessary to ensure that the class is being properly encapsulated?
A. Change the access modifier of the setradius () method to private
B. Change the getArea () method:
public double getArea () { return area; }
C. When the radius is set in the Circle constructor and the setRadius () method, recomputed the area and store it into the area field
D. Change the getRadius () method:
public double getRadius () {
area = Math.PI * radius * radius;
return radius;
}
Answer: ABC
http://www.passleader.com/1z0-803.html
QUESTION 68
Given a code fragment:
StringBuilder sb = new StringBuilder ();
String h1 = “HelloWorld”;
sb.append(“Hello”).append (“world”);
if (h1 == sb.toString()) {
System.out.println(“They match”);
}
if (h1.equals(sb.toString())) {
System.out.println(“They really match”);
}
What is the result?
A. They match
They really match
B. They really match
C. They match
D. Nothing is printed to the screen
Answer: D
QUESTION 69
Which two are possible outputs?
public class Two {
public static void main(String[] args) {
try {
doStuff();
system.out.println(“1”);
}
catch {
system.out.println(“2”);
}}
public static void do Stuff() {
if (Math.random() > 0.5) throw new RunTimeException(); doMoreStuff();
System.out.println(“3 “);
}
public static void doMoreStuff() {
System.out.println(“4”);
}
}
A. 2
B. 4
3
1
C. 1
D. 1
2
Answer: AB
QUESTION 70
Given:
public class MyFor {
public static void main(String[] args) {
for (int ii = 0; ii < 4; ii++) {
System.out.println(“ii = “+ ii);
ii = ii +1;
}
}
}
What is the result?
A. ii = 0
ii = 2
B. ii = 0
ii = 1
ii = 2
ii = 3
C. ii =
D. Compilation fails.
Answer: A
QUESTION 71
Given the code fragment:
int [][] array2d = new int[2][3];
System.out.println(“Loading the data.”);
for ( int x = 0; x < array2d.length; x++) {
for ( int y = 0; y < array2d[0].length; y++) {
System.out.println(” x = ” + x);
System.out.println(” y = ” + y);
// insert load statement here.
}
}
System.out.println(“Modify the data. “);
for ( int x = 0; x < array2d.length; x++) {
for ( int y = 0; y < array2d[0].length; y++) {
System.out.println(” x = ” + x);
System.out.println(” y = ” + y);
// insert modify statement here.
}
}
Which pair of load and modify statement should be inserted in the code?
The load statement should set the array’s x row and y column value to the sum of x and y.
The modify statement should modify the array’s x row and y column value by multiplying it by 2.
A. Load statement: array2d(x,y) = x + y;
Modify statement: array2d(x,y) = array2d(x,y) * 2
B. B. Load statement: array2d[x y] = x + y;
Modify statement: array2d[x y] = array2d[x y] * 2
C. Load statement: array2d[x,y] = x + y;
Modify statement: array2d[x,y] = array2d[x,y] * 2
D. Load statement: array2d[x][y] = x + y;
Modify statement: array2d[x][y] = array2d[x][y] * 2
E. Load statement: array2d[[x][y]] = x + y;
Modify statement: array2d[[x][y]] = array2d[[x][y]] * 2
Answer: D
QUESTION 72
Given:
public class DoBreak1 {
public static void main(String[] args) {
String[] table = {“aa”, “bb”, “cc”, “dd”};
for (String ss: table) {
if ( “bb”.equals(ss)) {
continue;
}
System.out.println(ss);
if ( “cc”.equals(ss)) {
break;
}
}
}
}
What is the result?
A. aa
cc
B. aa
bb
cc
C. cc
dd
D. cc
E. Compilation fails.
Answer: A
QUESTION 73
Which three lines are illegal?
1. class StaticMethods {
2. static void one() {
3. two();
4. StaticMethods.two();
5. three();
6. StaticMethods.four();
7. }
8. static void two() { }
9. void three() {
10. one();
11. StaticMethods.two();
12. four();
13. StaticMethods.four();
14. }
15. void four() { }
16. }
A. line 3
B. line 4
C. line 5
D. line 6
E. line 10
F. line 11
G. line 12
H. line 13
Answer: CDH
QUESTION 74
Which is a valid abstract class?
A. public abstract class Car {
protected void accelerate();
}
B. public interface Car {
protected abstract void accelerate();
}
C. public abstract class Car {
protected final void accelerate();
}
D. public abstract class Car {
protected abstract void accelerate();
}
E. public abstract class Car {
protected abstract void accelerate() {
//more car can do
}}
Answer: D
QUESTION 75
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