Solved

Class Animal

Question 54

Essay

class Animal
{  
    void myDog()  
    {  
        System.out.println("Animal stuff");  
    }  
}  
        
      
class Dog extends Animal
{  
     void mydog()  
    {  
        System.out.println("Dog stuff");  
    }  
    public static void main(String args[])  
    {  
        Dog d = new Dog();  
        d.myDog();  
        super.myDog();  
    }  
}
The above code gives a compiler error stating that the non-static variable super cannot be
referenced from a static context super.myDog(); . Explain why the error occurs and describe what changes you could make for the code to be executable.

Correct Answer:

verifed

Verified

The main method is static , and it can o...

View Answer

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents