Menu
Topics Index
...
`

Class with multiple static methods1931


If you need explanation Read this topic If you need explanation Read this topic

If you need Answer Take test on this topic

Class with multiple static methods1931
What will be the output of the following program?
public class ClassTest {
    public static void main(String[] args) {
        System.out.println("Class ClassTest");
    }
    public static class A {
        A() {
            System.out.println("Class A");
        }
    }
    public static class B {
        B() {
            System.out.println("Class B");
        }
    }
}

A. Class ClassTest
Class A
Class B
B. Class ClassTest
Class A
C. Class ClassTest
Class B
D. Class A
Class B
E. Some other output
F. Compilation Error or Runtime Error
Topic: Java Multiple Methods In One Class Creating Static Methods In Java Using Static Keyword

If you need explanation Read this topic If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans: e
if a object created then only constructer works automatically
here no object created
so output is
class test class

Posted by Ananda Kumar    2014-05-02 03:48:05


Ans is E some other output Class ClassTest is obtained as Class A and B is out of scope to Class classTest

Posted by Bharath Yelchuri    2014-05-02 03:48:46


ans is F java doesn't allow multiple public classes in same file :)

Posted by Akash Kolariya    2014-05-02 04:50:58


Congratulations Ananda Kumar. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-05-05 04:40:21


© meritcampus 2019

All Rights Reserved.

Open In App