Menu
Question Index
...

What will be the output of following program?

public class Fruit {

    String colour = "green";
    int prize = 12;
    String taste = "sweet";

    public static void main(String args[]) {
        Fruit orange = new Fruit();
        System.out.println(orange.taste);
        System.out.println(orange.prize);
        System.out.println(orange.colour);
    }
}


sweet
12
green
green
12
sweet
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Member Variable In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App