Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help me java 1.Write a single statment that declares a reference variable

ID: 3926548 • Letter: P

Question

please help me java

1.Write a single statment that declares a reference variable of type Elevator named myLift and instantiates an object of type Elevator, passing an initial int value of 22 to the constructor of class for its initial floor.

2.Assume a class named Logger has a public static method, printErrorDescription , that accepts one int argument and returns an int value. Write a single statintment that invokes the method printErrorDescription , passing it the value 14, and returning a value back to the int variable exitcode.

Explanation / Answer


1.
   To create an object, you need to use 'new' keyword and proper constructor of that class
   Elevator myLift = new Elevator(22);

2.
   To call static method, we do not need to create a object of that class. We can call all static members using class name.
int exitcode = Logger.printErrorDescription(14);