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

Question 6.6. (TCOs 1, 2, and 6) If a class contains a main method, that method

ID: 3804141 • Letter: Q

Question

Question 6.6. (TCOs 1, 2, and 6) If a class contains a main method, that method is executed (Points : 3)

       automatically when the class is run.
       when another method within the class calls it.
       when an object is created from the class.
       None of the above

       to the left of the decimal point
       centered
       to the right of the decimal point
       None of the above

       getNum needs a parameter.
       getNum must be private.
       getNum must return int, not void.
       Code is correct as is.

. (TCOs 1, 2, and 6) The format specifier %.2f specifies that two digits of precision should be output _____ in the floating-point number. (Points : 3)

Explanation / Answer

3)

Ans)automatically when the class is run.

Reason:

when we run the class jvm searches for the main() method.if founds, it will call automatically and gets executed as it is static.

______________

4)The format specifier %.2f specifies that two digits of precision should be output _____ in the floating-point number.

Ans)to the left of the decimal point

______________

5)

What error, if any, is in the following code?
public class Test
{
         private int num;
         public void getNum( )
         {
                  return num;
         }
}

Ans)getNum must return int, not void.

__________________

6)

Ans)6

reasion:

Rental r = new Rental(); //creating the rental class object
r.setNumOfPersons(5); //Setting the no of person to 5
                  r.addPerson(); //When we call this method ,then the no of persons will be incremented to 6
                  System.out.println(r.getNumOfPersons()); //Displaying the number of persons as 6

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote