Oracle 1Z0-803 Online Practice
Questions and Exam Preparation
1Z0-803 Exam Details
Exam Code
:1Z0-803
Exam Name
:Java SE 7 Programmer I
Certification
:Oracle Certifications
Vendor
:Oracle
Total Questions
:216 Q&As
Last Updated
:Oct 18, 2021
Oracle 1Z0-803 Online Questions &
Answers
Question 91:
Given the code fragment:
What is the result?
A. Valid B. Not valid C. Compilation fails D. An IllegalArgumentException is thrown at run time
C. Compilation fails
In segment 'if (valid)' valid must be of type boolean, but it is a string. This makes the compilation fail.
Question 92:
Given the code fragment:
What values of x, y, z will 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
E. X = 2, Y = 3, Z = 4
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.
Question 93:
Given:
What is true about the class Wow?
A. It compiles without error. B. It does not compile because an abstract class cannot have private methods. C. It does not compile because an abstract class cannot have instance variables. D. It does not compile because an abstract class must have at least one abstract method. E. It does not compile because an abstract class must have a constructor with no arguments.
A. It compiles without error.
Question 94:
Given:
package p1;
public interface DoInterface {
void method1(int n1); // line n1
}
package p3;
import p1.DoInterface;
public class DoClass implements DoInterface {
public DoClass(int p1) { }
public void method1(int p1) { } // line n2
private void method2(int p1) { } // line n3
}
public class Test {
public static void main(String[] args) {
DoInterface doi= new DoClass(100); // line n4
doi.method1(100);
doi.method2(100);
}
}
Which change will enable the code to compile?
A. Adding the public modifier to the declaration of method1 at line n1 B. Removing the public modifier from the definition of method1 at line n2 C. Changing the private modifier on the declaration of method 2 public at line n3 D. Changing the line n4 DoClass doi = new DoClass ( );
C. Changing the private modifier on the declaration of method 2 public at line n3
Private members (both fields and methods) are only accessible inside the class they are declared or inside inner classes. private keyword is one of four access modifier provided by Java and its a most restrictive among all four e.g. public, default(package), protected and private.
Which option lists only those classes that belong to the unchecked exception category?
A. AssertionError, ArrayIndexOutOfBoundsException, ArithmeticException B. AssertionError, IOError, IOException C. ArithmeticException, FileNotFoundException, NumberFormatException D. FileNotFoundException, IOException, SQLException E. ArrayIndexOutOfBoundException, IllegalArgumentException, FileNotFoundException
A. AssertionError, ArrayIndexOutOfBoundsException, ArithmeticException
Not B: IOError and IOException are both checked errors. Not C, not D, not E: FileNotFoundException is a checked error.
Note:
Checked exceptions:
*
represent invalid conditions in areas outside the immediate control of the program (invalid user input, database problems, network outages, absent files)
*
are subclasses of Exception
*
a method is obliged to establish a policy for all checked exceptions thrown by its implementation (either pass the checked exception further up the stack, or handle it somehow)
Note:
Unchecked exceptions:
*
represent defects in the program (bugs) - often invalid arguments passed to a non-private method. To quote from The Java Programming Language, by Gosling, Arnold, and Holmes: "Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program's logic and cannot be reasonably recovered from at run time."
*
are subclasses of RuntimeException, and are usually implemented using IllegalArgumentException, NullPointerException, or IllegalStateException
*
method is not obliged to establish a policy for the unchecked exceptions thrown by its implementation (and they almost always do not do so)
Question 96:
Which two may precede the word `class' in a class declaration?
A. local B. public C. static D. volatile E. synchronized
B. public C. static
B: A class can be declared as public or private.
C: You can declare two kinds of classes: top-level classes and inner classes. You define an inner class within a top-level class. Depending on how it is defined, an inner class can be one of the following four types: Anonymous, Local, Member
and Nested top-level. A nested top-level class is a member classes with a static modifier. A nested top-level class is just like any other top-level class except that it is declared within another class or interface. Nested top-level classes are
typically used as a convenient way to group related classes without creating a new package.
The following is an example:
public class Main { static class Killer {
Question 97:
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. 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
D. Load statement: array2d[x][y] = x + y; Modify statement: array2d[x][y] = array2d[x][y] * 2
Question 98:
Which two actions will improve the encapsulation of a class?
A. Changing the access modifier of a field from public to private B. Removing the public modifier from a class declaration C. Changing the return type of a method to void D. Returning a copy of the contents of an array or ArrayList instead of a direct reference
A. Changing the access modifier of a field from public to private D. Returning a copy of the contents of an array or ArrayList instead of a direct reference
Which code fragment, when inserted at // insert code here, enables the code to compile and and print a b c?
A. List update (String[] strs) B. Static ArrayListupdate(String [] strs) C. Static List update (String [] strs) D. Static void update (String[] strs) E. ArrayList static update(String [] strs)
E. ArrayList static update(String [] strs)
Question 100:
Given:
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; }
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; }
Nowadays, the certification exams become more and more important and required by more and more
enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare
for the exam in a short time with less efforts? How to get a ideal result and how to find the
most reliable resources? Here on Vcedump.com, you will find all the answers.
Vcedump.com provide not only Oracle exam questions,
answers and explanations but also complete assistance on your exam preparation and certification
application. If you are confused on your 1Z0-803 exam preparations
and Oracle certification application, do not hesitate to visit our
Vcedump.com to find your solutions here.