Object & Classes


  1. What is the value of “n” after this line of code has been executed?
    double n = Math.round ( 4.5 + Math.random() );











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    The Math.random() method returns a number greater than or equal to 0 and less than 1. so 4.5 will be greater than or equal to 4.5 and less than 5.5, we can be sure that Math.round() will round that number to 5.


  1. Which of these class encapsulate the runtime state of an object or an interface?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Class



  1. Which of these classes can schedule task for execution in future?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Timer and TimerTask are the classes that support the ability to schedule tasks for execution at some future time.


  1. Which of these method is a rounding function of Math class?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    max(), min() and abs() are all rounding functions.



  1. What is the value of double consonant ‘E’ defined in Math class?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    approximately 2.72