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. 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?
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
What is the result? 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.