Premium

Oracle Java Programming Certification Questions and Answers (Dumps and Practice Questions)



Question : A method doSomething () that has no exception handling code is modified to trail a method that throws a checked exception. Which two modifications, made independently,
will allow the program to compile?

A. Catch the exception in the method doSomething().
B. Declare the exception to be thrown in the doSomething() method signature.
C. Cast the exception to a RunTimeException in the doSomething() method.
D. Catch the exception in the method that calls doSomething().
 : A method doSomething () that has no exception handling code is modified to trail a method that throws a checked exception. Which two modifications, made independently,
1. A,B
2. B,C
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,D

5. A,C



Correct Answer : Get Lastest Questions and Answer :
Explanation: Valid Java programming language code must honor the Catch or Specify Requirement.
This means that code that might throw certain exceptions must be enclosed by either of the following:
- A try statement that catches the exception. The try must provide a handler for the exception, as described in Catching and Handling Exceptions.
- A method that specifies that it can throw the exception. The method must provide a throws clause that lists the exception, as described in Specifying the Exceptions Thrown by
Method. Code that fails to honor the Catch or Specify Requirement will not compile.









Question : Given:
class X {}
class Y { Y ( ) { } }
class Z { Z (int i ) { } }
Which class has a default constructor ?

 : Given:
1. X only

2. Y only

3. Access Mostly Uused Products by 50000+ Subscribers

4. X and Y
E. Y and Z
5. Y and Z

Correct Answer : Get Lastest Questions and Answer :
Explanation:






Question : The protected modifier on a Field declaration within a public class means that the field .
 : The protected modifier on a Field declaration within a public class means that the field .
1. Cannot be modified
2. Can be read but not written from outside the class
3. Access Mostly Uused Products by 50000+ Subscribers
4. Can be read and written from this class and its subclasses defined in any package




Correct Answer : Get Lastest Questions and Answer :

Explanation:




Related Questions


Question : You have been given following code.

public class Two {

public static void main(String[] args) {
try {
doStuff();
System.out.print("1");
} catch (Exception e) {
System.out.print("2");
}
}

public static void doStuff() {
if (Math.random() > 0.5)
throw new RuntimeException();
doMoreStuff();
System.out.print("3 ");
}

public static void doMoreStuff() {
System.out.print("4");
}
}


Which two are possible outputs?

A. 2
B. 4 3 1
C. 1
D. 1 2

  : You have been given following code.
1. A,B
2. B,C
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,D
5. C,D




Question : You have been given below code

public class Two {

public static void main(String[] args) {
int day = 1;
switch (day) {
case "7": System.out.print("Uranus");
case "6": System.out.print("Saturn");
case "1": System.out.print("Mercury");
case "2": System.out.print("Venus");
case "3": System.out.print("Earth");
case "4": System.out.print("Mars");
case "5": System.out.print("Jupiter");
}
}
}

Which two modifications, made independently, enable the code to compile and run?
A. Adding a break statement after each print statement
B. Adding a default section within the switch code-block
C. Changing the string literals in each case label to integer
D. Changing the type of the variable day to String
E. Arranging the case labels in ascending order

  : You have been given below code
1. A,B
2. B,C
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,E
5. A,C



Question : 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


  : Which three are advantages of the Java exception mechanism?
1. A,B,C
2. B,C,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,C,E
5. A,D,E




Question : Identify two benefits of using ArrayList over array in software development.
A. reduces memory footprint
B. implements the Collection API
C. is multithread safe
D. dynamically resizes based on the number of elements in the list



 : Identify two benefits of using ArrayList over array in software development.
1. A,B
2. A,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. C,D





Question : You have been given below code


Public Class Test {}

Which two packages are automatically imported into the java source file by the java compiler?s

A. Java.lang
B. Java.awt
C. Java.util
D. Javax.net
E. Java.*
F. The package with no name


  :  You have been given below code
1. A,B
2. A,F
3. Access Mostly Uused Products by 50000+ Subscribers
4. C,D
5. E,F






Question : Which is a valid abstract class?

 : Which is a valid abstract class?
1. public abstract class Car { protected void accelerate();}
2. public interface Car {protected abstract void accelerate();}
3. Access Mostly Uused Products by 50000+ Subscribers
4. public abstract class Car { protected abstract void accelerate();}

5. public abstract class Car { protected abstract void accelerate() { //more car can do}}