Menu
Question Index
...

What will be the output of the following program?

class DefineClasses
{
    int c;

    public static void main(String[] args)
    {
        A a = new A();
        B b = new B();
        System.out.println("a = " + a.a);
        System.out.println("b = " + b.b);
        System.out.println("c = " + c);
    }
}

class A { int a; }

class B { int b = 5; }


a = 0
b = 5
c = 0
a = 0
b = 0
c = 0
Compilation Error
Runtime Exception

Doubts

Problems

Topic: Static and Non Static Variables - Static and Non Static Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App