adplus-dvertising
frame-decoration

Question

What is the output of this program?
    class average {
        public static void main(String args[])
        {
            double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
            double result;
            result = 0;
            for (int i = 0; i < 6; ++i) 
                result = result + num[i];
	    System.out.print(result/6);
 
        } 
    }

a.

16.34

b.

16.566666644

c.

16.46666666666667

d.

16.46666666666666

Posted under Java Programming

Answer: (c).16.46666666666667

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?

Similar Questions

Discover Related MCQs

Q. How to format date from one form to another?

Q. How to convert Date object to String?

Q. How to convert a String to a Date object?

Q. Is SimpleDateFormat thread safe?

Q. How to identify if a timezone is eligible for DayLight Saving?

Q. What is the replacement of joda time library in java 8?

Q. How is Date stored in database?

Q. What does LocalTime represent?

Q. How to get difference between two dates?

Q. How to get UTC time?

Q. Which of these is an incorrect string literal?

Q. Which two cause a compiler error?

1. float[ ] f = new float(3);
2. float f2[ ] = new float[ ];
3. float[ ]f1 = new float[3];
4. float f3[ ] = new float[3];
5. float f5[ ] = {1.0f, 2.0f, 2.0f};

Q. Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class?

Q. Which is a valid declaration within an interface?

Q. You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?

Q. Which three form part of correct array declarations?

1. public int a [ ]
2. static int [ ] a
3. public [ ] int a
4. private int a [3]
5. private int [3] a [ ]
6. public final int [ ] a

Q. public class Test { }

What is the prototype of the default constructor?

Q. What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package?

Q. Which of the following is/are legal method declarations?

1. protected abstract void m1();
2. static final void m1(){}
3. synchronized public final void m1() {}
4. private native void m1();

Q. Which cause a compiler error?