Premium

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



Question : An unchecked exception occurs in a method dosomething() Should other code be added in the dosomething() method for it to compile and execute?

 : An unchecked exception occurs in a method dosomething() Should other code be added in the dosomething() method for it to compile and execute?
1. The Exception must be caught
2. The Exception must be declared to be thrown.
3. Access Mostly Uused Products by 50000+ Subscribers
4. No other code needs to be added.



Correct Answer : Get Lastest Questions and Answer :
Explanation: Because the Java programming language does not require methods to catch or to specify
unchecked exceptions (RuntimeException, Error, and their subclasses), programmers may be
tempted to write code that throws only unchecked exceptions or to make all their exception
subclasses inherit from RuntimeException. Both of these shortcuts allow programmers to
write code without bothering with compiler errors and without bothering to specify or to
catch any exceptions. Although this may seem convenient to the programmer, it sidesteps the
intent of the catch or specify requirement and can cause problems for others using your
classes.







Question : Which two statements are true for a two-dimensional array of primitive data type?
A. It cannot contain elements of different types.
B. The length of each dimension must be the same.
C. At the declaration time, the number of elements of the array in each dimension must be specified.
D. All methods of the class object may be invoked on the two-dimensional array.

 : Which two statements are true for a two-dimensional array of primitive data type?
1. A,B
2. B,C
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,D



Correct Answer : Get Lastest Questions and Answer :







Question : A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the result?

 : A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the result?
1. Compilation fails.
2. The third argument is given the value null.
3. Access Mostly Uused Products by 50000+ Subscribers
4. The third argument is given the value zero.
5. The third argument is given the appropriate false value for its declared type.



Correct Answer : Get Lastest Questions and Answer :
Explanation: The problem is noticed at build/compile time. At build you would receive an error message like: required: int,int,int found: int,int



Related Questions


Question : You have been given below code

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 would be printed ?

 : You have been given below code
1. aa cc
2. aa bb cc
3. Access Mostly Uused Products by 50000+ Subscribers
4. cc

5. Compilation fails.




Question : You have been given following code

public class TestOperator {
public static void main(String[] args) {
int result = 30 - 12 / (2 * 5) + 1;
System.out.print("Result = " + result);
}
}

What is the result?


 : You have been given following code
1. Result = 2
2. Result = 3
3. Access Mostly Uused Products by 50000+ Subscribers
4. Result = 29
4. Result = 30





Question : Which three are bad practices?

A. Checking for ArrayIndexoutofBoundsException when iterating through an array to determine when all elements have been visited
B. Checking for Error and. If necessary, restarting the program to ensure that users are unaware problems
C. Checking for FileNotFoundException to inform a user that a filename entered is not valid
D. Checking for ArrayIndexoutofBoundsException and ensuring that the program can recover if one occur
E. Checking for an IOException and ensuring that the program can recover if one occurs

 : Which three are bad practices?
1. A,B,C
2. B,C,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,B,D
5. B,C,D




Question : You have been given following code fragment

String[] cartoons = { "tom", "jerry", "micky", "tom" };
int counter = 0;
if ("tom".equals(cartoons[0])) {
counter++;
} else if ("tom".equals(cartoons[1])) {
counter++;
} else if ("tom".equals(cartoons[2])) {
counter++;
} else if ("tom".equals(cartoons[3])) {
counter++;
}
System.out.print(counter);

What would be printed , when executed ?
 : You have been given following code fragment
1. 1
2. 2
3. Access Mostly Uused Products by 50000+ Subscribers
4. 0





Question : Which statement is true about the default constructor of a top-level class?

 :  Which statement is true about the default constructor of a top-level class?
1. It can take arguments.
2. It has private access modifier in its declaration.
3. Access Mostly Uused Products by 50000+ Subscribers
4. The default constructor of a subclass always invokes the no-argument constructor of its superclass.




Question : You have been given below code

List colors = new ArrayList();
colors.add("green");
colors.add("red");
colors.add("blue");
colors.add("yellow");
colors.remove(2);
colors.add(3, "cyan");
System.out.print(colors);


 : You have been given below code
1. [green, red, yellow, cyan]
2. [green, blue, yellow, cyan]
3. Access Mostly Uused Products by 50000+ Subscribers
4. An IndexOutOfBoundsException is thrown at runtime