Menu
Question Index
...

What will be the output of the following program?

public class Mother {
    public static void main(String args[]) {
        Children a = new Children(16.0, 15.0);
        double average = getAverage(a.ch1, a.ch2);
        double biggerAge = getBigger(a.ch1, a.ch2);
        System.out.print(average + ", " + biggerAge);
    }
    public static double getAverage(double ch1, double ch2) {
        return ((ch1 + ch2 - ch1) + ch1) / 2;
    }
    public static double getBigger(double ch1, double ch2) {
        return (ch1 > ch2 ? ch1 : ch2);
    }
}
class Children {
    double ch1;
    double ch2;
    Children(double c1, double c2) {
        ch1 = c1;
        ch2 = c2;
    }
}


15.0,16.0
15.5,16.0
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Program To Find Rectangle Area & Perimeter Using Classes

Read this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App