Menu
Topics Index
...
`

This keyword


If you need explanation Read this topic

If you need Answer Take test on this topic

This keyword
Which of the following statement is used at LINE K to print the message "Hello MeritCampus"?
public class InsertLine extends SuperClass {
    public static void main(String[] args) {
        InsertLine object1 = new InsertLine();
        object1.printMsg();
    }
    public void printMsg() {
        //LINE K
    }
}
class SuperClass {    MC obj_MC = new MC();    }
class MC {    String str = "Hello MeritCampus";    }

A. System.out.println(MC.str);
B. System.out.println(str);
C. System.out.println(this.obj_MC.str);
D. Some other statement
Topic: Is-A Relationship In Java

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.

C is the answer..

Posted by Shabaaz Shaikz    2013-09-05 04:38:02


c is the answer since str is an instance variable we have to access it with the help of an oblect

Posted by Shashanka Mogaliraju    2013-09-05 05:25:46


The Correct answer is C. There is no winner for this dose, even though Shabaaz Shaikz answered but there is no explanation and Shashanka Mogaliraju answered correctly, he already won in this week. So, as per our rules (as mentioned on top) he is not eligible. :(

Posted by Merit Campus    2013-09-06 03:43:26


© meritcampus 2019

All Rights Reserved.

Open In App