Knowee
Questions
Features
Study Tools

Select the correct answerPredict the output of the following program.class codetantra{  public static void main(String[] args)  {    Double object = new Double("2.4");    int p = object.intValue();    byte q = object.byteValue();    float r = object.floatValue();    double s = object.doubleValue();     System.out.println(p + q + r + s );   }}Options8.888.800000095367432

Question

Select the correct answerPredict the output of the following program.class codetantra{  public static void main(String[] args)  {    Double object = new Double("2.4");    int p = object.intValue();    byte q = object.byteValue();    float r = object.floatValue();    double s = object.doubleValue();     System.out.println(p + q + r + s );   }}Options8.888.800000095367432

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the program will be 8.800000095367432.

Here's the step by step explanation:

  1. A Double object is created with the value "2.4".
  2. The intValue() method is called on the object, which converts the double value to an integer. Since 2.4 is a double, the decimal part is truncated, and the value of p becomes 2.
  3. The byteValue() method is called on the object, which converts the double value to a byte. Again, the decimal part is truncated, and the value of q becomes 2.
  4. The floatValue() method is called on the object, which converts the double value to a float. The value of r becomes 2.4.
  5. The doubleValue() method is called on the

This problem has been solved

Similar Questions

the correct answerWhat will be the output of the following Java code?    class codetantra     {        public static void main(String args[])         {            double m = 295.30;            int  n = 330;            byte o = (byte) m;            byte p = (byte) n;            System.out.println(o + " "  + p);        }     }

elect the correct answerWhat is the output of the following program? public class Test{  private String function(float i, int f)  {    return ("ctc");  }  private String function(double i, double f)  {    return ("CTC");  }  public static void main(String[] args)  {    Test obj = new Test();    System.out.println(obj.function(1., 20));     }}OptionsRuntime errorCompilation errorCTCCodeTantraCode

Select the correct answerWhat will be the output of the following Java program?class Output   {     public static void main(String args[])     {      double ct1 = 3.0;        double ct2 = 2.0;      double ct3 = Math.pow( ct1, ct2 );      System.out.print(ct3);    }  }Options3.02.09.08.0

What is the output of the following code?public class Solution { public static void main(String args[]) { double x = 79.85; System.out.println(Math.round(x)); } } Options: Pick one correct answer from below798079.8None of the above

elect the correct answerWhat is the output of the following program?public class Score{    public static void main(String[] args)    {        double data = 222.423;        int sum = 3;        float value = 2.1f;        System.out.println(data + sum + value);              }}Options227.52299222222.423222.5

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.