Menu
Topics Index
...
`

Classes854


If you need explanation Read this topic

If you need Answer Take test on this topic

Classes854
Which of the following can be inserted at LINE M?
class MeritCampus
{
        public static void main(String [] args)
        {
    
        }
}
class Merit
{
        Merit(String s)
        {
    
        }
    
        Merit()
        {
    
        }
}

class Campus extends Merit
{
        Campus()
        {
    
        }
    
        Campus(String s)
        {
            super(s);
        }
    
        void insert()
        {
            //LINE M
        }
}

A. Merit f = new Campus() { };
B. Merit f = new Merit(24) { };
C. Campus f = new Merit(String s) { };
D. Merit f = new Merit.Campus(String s) { };
Topic: Inheritance And Constructors 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.

D

Posted by Akshay Bansod    2014-12-24 12:18:03


Ans is A...here we have the Merit class as Parent nad Campus as Child class...here we have 4 options..
A) we can create the instance for the Merit class and we are writing the code there it self Bcz we want some different operation for this object creation..if we create normally than default constructor get invoked...but we need some different code that's why we write like this..
B) we cant create the instance for the Merit  by passing the int Bcz no suitable constructor found
C) Child class Reference can not refer parent class Object
D) here Campus is Child class Not An inner class..if it inner class we refer it by using the outer class name with ...

Posted by Uday Kumar    2014-12-24 15:43:32


a

Posted by Shubham Bansal    2014-12-24 15:51:12


This dose is now closed and the winners are Uday Kumar,  for 'First Correct Comment', Uday Kumar,  for 'Best Comment' and Uday Kumar for the 'Popular Comment'. The 'lucky liker' is Sai Ram. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2014-12-25 05:32:49


© meritcampus 2019

All Rights Reserved.

Open In App