Premium

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



Question : You have been given two classes as shown.
What will be printed when executed.



 : You have been given two classes as shown.
1. Welcome HadooExam
Welcome HadooExam
2.
Welcome StringBuilder@(Alpha numeric HashcodeValue)
Welcome MyUtility@(Alpha numeric HashcodeValue)
3. Access Mostly Uused Products by 50000+ Subscribers
Welcome MyUtility@(Alpha numeric HashcodeValue)
4. Compilation will fail in MyApp class.

Correct Answer : Get Lastest Questions and Answer :




Question : You have been given code as shown image. Please select line number on which compilation fails.

A. Line 7
B. Line 8
C. Line 9
D. Line 10
E. Line 11
F. Line 12

 : You have been given code as shown image. Please select line number on which compilation fails.
1. A,B,C
2. A,D,F
3. Access Mostly Uused Products by 50000+ Subscribers
4. C,D,F


Correct Answer : Get Lastest Questions and Answer :

Explanation:








Question : You have been given below code

default void hadoopexam(){}

Which statement is true?


 : You have been given below code
1. This method is invalid.
2. This method can be used only in an interface.
3. Access Mostly Uused Products by 50000+ Subscribers
4. This method can be used only in an interface or an abstract class.
5. None of above.






Correct Answer : Get Lastest Questions and Answer :


Explanation: Given method is declared as default method so we can use it only inside an interface. Hence option 1is correct and option 4 is incorrect.
Option 1 is incorrect as it is valid method. Option 3 is incorrect as return type is void, which means we can't return anything.





Related 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




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


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





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