Menu
Question Index
...

What will be the output of the following program?

class SamsungMobile
{
    public static void main(String[] args)
    {
        Simple.getData();
        Simple.display();
    }
}
class Simple
{
    static int a, b = 20;
    static void getData()
    {
        System.out.println("a = " + a);
    }
    static void display()
    {
        System.out.println("b = " + b);
    }
    static
    {
        System.out.println("Samsung Mobile");
        a = 4 * b;
    }
}


Samsung Mobile
a = 0
b = 20
Samsung Mobile
a = 80
b = 20
a = 0
b = 20
Compilation Error
Runtime Error

Doubts

Problems

Topic: Creating Static Methods In Java Using Static Keyword

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App