Premium

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



Question : Given the following two classes:
How should you write methods in the ElectricAccount
class at line n1 so that the member variable
bill is always equal to the value of the member
variable kwh multiplied by the member variable rate?

Any amount of electricity used by a customer
(represented by an instance of the customer class)
must contribute to the customer's bill
(represented by the member variable bill)
through the method useElectricity method.
An instance of the customer class should never be able to tamper
with or decrease the value of the member variable bill.
 :  Given the following two classes:
1. A
2. B
3. C
4. D


Correct Answer :2




Question :
 :
1. A,B
2. B,C
3. A,C
4. D,E

4. A,E



Correct Answer : 3





Question : Given:

Car c1 = new Car("Auto");
Car c2 = new Car("4W" , 150 , "Manual");
System.out.println(c1.type + " " + c1.maxSpeed + " " + c1.trans);
System.out.println(c2.type + " " + c2.maxSpeed + " " + c2.trans);

What is the result?

 :  Given:
1. 4W 100 Auto
4W 150 Manual
2. Null 0 Auto
4W 150 Manual
3. Compilation fails only at line n1
4. Compilation fails only at line n2
5. Compilation fails at both line n1 and line n2


Correct Answer : 3




Related Questions


Question : Given the code fragment:

What is the result?
  : Given the code fragment:
1. Execution terminates in the first catch statement, and caught a RuntimeException is printed to the console
2. Execution terminates In the second catch statement, and caught an Exception is printed to the console.
3. Access Mostly Uused Products by 50000+ Subscribers
4. Execution completes normally, and "Ready to use" is printed to the console.
5. The code fails to compile because a throws keyword is required.





Question : When you run the given program, what would be printed.


 : When you run the given program, what would be printed.
1. int sum is 30
float sum is 30.0
2. int sum is 30
double sum is 30.0
3. Access Mostly Uused Products by 50000+ Subscribers
double sum is 30.0
4. Integer sum is 30
flaot sum is 30.0

Correct answer: 2



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

 : When you run the given program, what would be printed.
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 : You have been given code as shown, what happen when you compile/run

  : You have been given code as shown, what happen when you compile/run
1. It will print 10:20
2. It will print 0:20
3. Access Mostly Uused Products by 50000+ Subscribers
4. Compilation fails at line n1
5. Compilation fails at line n2


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.


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



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.