Menu
Question Index
...

What will be the output of the following program?

class FoodItems
{
    public static void main(String s[])
    {
        Noodles eat = new Noodles();
        eat.print();
    }
}

class Maggi
{
    private int spoon = 3;
    private int sticks = 4;
}

class Noodles extends Maggi
{
    private int powder = 1;
    private int fire = 2;

    void print()
    {
        System.out.println(powder + " " + fire + " " + sticks + " " + spoon);
    }
}


1 2 4 3
1 2 4
Compilation Error
Runtime Error

Doubts

Problems

Topic: Using private Keyword In Java For Access Control

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App