Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

E. public void Decide Result (int x, double value, DC 2. For the following lines of code, write Wif it's Wrong and it it's Correct.

image text in transcribed
image text in transcribed
E. public void Decide Result (int x, double value, DC 2. For the following lines of code, write Wif it's Wrong and it it's Correct. (2 pts) public class StaticDemo private int i = 2; private static int k = 0; public static void main(String[] args) i = 20; int x - method2 (1, 2); methodl(); // (Write w or c) (Write w or c) (Write w or c) public void methodi () i + k + method2 (1,2); // Wrong Correct public static int method2(int x, int y) return (x + y); 3. Write the output generated by the following class when it is run. (2 pts) public class Mystery private int my opone; private int my_opTwo; public Mystery int opOne, int opTwo ) my_opone = opOne; my opTwo - opTwo; public String toString() return my_opone + ", " + my_op'Two; public void doSomething () my opOne - my opOne + 1; my_opTwo - my opTwo - 1; Write Output Here public static void main(String[] args) Mystery Mystery = new Mystery [ 9. 3): System.out.println Mystery.toString()) aMystery.doSomething l); System.out.println Mystery.toString()) aNystery.doSomething) System.out.println( aMystery.toString() ): 4. According to the following UML diagram, write a complete class Car. (4 pts) Car -year Model:int 1900 -make: String = "7" -speed: double = 0.0 Car() +getYearModel( ):int +getMake(): String +getSpeed(): double setYear Model(int): void +setMake(String): void +accelerate(): void +brake(): void +toString(): String Note: If we run the following driver class on Car, the program must generate the output shown at the bottom. class Test Car public static void main(String[] args) Car myCar = new Car(); mycar.set Year Model (2006) mycar.setMake Ford Taurus"); System.out.println(myCar); myCar accelerate() System.out.println("Current speed is: myCar.getSpeed() + " miles/per hour"); mycar.brake(); System.out.println("Current speed is: - myCar.getSpeed() + " miles/per hour) Output generated from above testing program Year: 2006 Make: Ford Taurus Speed: 0.0 Current speed is: 10.0 miles/per hour Current speed is: 5.0 miles/per hour

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions

Question

Explain the chemical properties of acids with examples.

Answered: 1 week ago

Question

Write the properties of Group theory.

Answered: 1 week ago

Question

=+j on to staff their operations in the global marketplace.

Answered: 1 week ago