Premium

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



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.






Question : Which statement initializes a stringBuilder to a capacity of ?

 : Which statement initializes a stringBuilder to a capacity of ?
1. StringBuilder sb = new String ("128");
2. StringBuilder sb = StringBuilder.setCapacity (128);
3. Access Mostly Uused Products by 50000+ Subscribers
4. StringBuilder sb = new StringBuilder (128);




Correct Answer : Get Lastest Questions and Answer :
Explanation: StringBuilder(int capacity)
Constructs a string builder with no characters in it and an initial capacity specified by the capacity argument.
Note: An instance of a StringBuilder is a mutable sequence of characters.
The principal operations on a StringBuilder are the append and insert methods, which are
overloaded so as to accept data of any type. Each effectively converts a given datum to a
string and then appends or inserts the characters of that string to the string builder. The
append method always adds these characters at the end of the builder; the insert method adds
the characters at a specified point.

Related Questions


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.







Question : Which statement initializes a stringBuilder to a capacity of ?

 : Which statement initializes a stringBuilder to a capacity of ?
1. StringBuilder sb = new String ("128");
2. StringBuilder sb = StringBuilder.setCapacity (128);
3. Access Mostly Uused Products by 50000+ Subscribers
4. StringBuilder sb = new StringBuilder (128);





Question : Given:

System.out.println("5 + 2 = " + 3 + 4 );
System.out.println("5 + 2 = " + (3 + 4) );

What is the result?

  : Given:
1. 5 + 2 = 34
5 + 2 = 34
2. 5 + 2 + 3 + 4
5 + 2 = 7
3. 7 = 7
7 + 7
4. 5 + 2 = 34
5 + 2 =7





Question : Given the code fragment:
System.out.printIn("Result: " + 2 + 3 + 5);
System.out.printIn("Result: " + 2 + 3 * 5);
What is the result?

 : Given the code fragment:
1. Result: 10 Result: 30
2. Result: 10 Result: 25
3. Result: 235 Result: 215
4. Result: 215 Result: 215

5. Compilation fails




Question : Given:

What is the result?



  : Given:
1. Base
DerivedA
2. Base
DerivedB
3. DerivedB
DerivedB
4. DerivedB
DerivedA
5. A classcast Except ion is thrown at runtime.