Menu
Question Index
...

What will be the output of the following program?

public class MyObject {
    public static void main(String[] args) {
        MyObject.myStaticMethod();
        System.out.println(MyObject.myStaticMethod());
    }

    public String memberVar;
    static private String memberStaticVar;
    static public String myStaticMethod() {
        memberVar = "Value";
        memberStaticVar = "Value";
        MyObject obj = new MyObject();
        obj.memberVar = "Value";
        System.out.println("Have a nice to Participants");
        return ("No Error");
    }
}


Have a nice to Participants
Have a nice to Participants
Have a nice to Participants
No Error
Have a nice to Participants
Have a nice to Participants
No Error
Have a nice to Participants
No Error
Some other output
Compilation Error or Runtime Error

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