• Login / Register
  • Articles
  • Universities
  • Jobs
  • Forum
  • IGNOU Assignments

  • IGNOU MCA Object Oriented Technologies and Java Programming MCS 024 Assignment 2018-2019
  • Solution - MCS 024 Question 1(a) - What is Object Oriented Programming?
  • MCS 024 Assignment 2018-19 question 3A Solution - IGNOU MCA
  • MCS 024 Assignment 2018-19 question 3B and 3C Solution
  • MCS 024 Assignment Question 4 Answer - IGNOU MCA
  • MCS 024 assignment Question 5 Solution
  • IGNOU MCS 024 solved assignment 2018-19 PDF
  • 2018-2019 IGNOU MCS 024 assignment question 1b solution
  • IGNOU MCS 024 question 1c solution - Write a program to explain use of Relational and Boolean operators in java.
  • IGNOU MCS 024 assignment 2018-19 question 2a solution
  • Solved MCS 024 assignment 2018-19 question 2B | IGNOU

MCS 024 Assignment Question 4 Answer - IGNOU MCA

Written by Neha Dubey on Oct 03, 2018

Check out solved MCS 024 assignment question 4 of IGNOU MCA second semester. What is polymorphism? Explain its advantages with the help of a program. What is constructor overloading? Explain the advantage of constructor overloading with the help of an exa

Objective

You will learn about the following in this guide / study material.

Fully solved question 4 of IGNOU MCS 024 assignment 2018-19.

IGNOU MCS 024 assignment 2018-19 Question 4 solution

Total three questions are there in IGNOU MCS 024 assignment question no.4. Let us see the answers for the given questions one by one.

Question 4(a) - What is polymorphism? Explain its advantages with the help of a program. (4 Marks)

Polymorphism

Polymorphism is the capability of a method to do different things based on the object through which it is invoked or object it is acting upon. For example method
find _area will work definitely for Circle object and Triangle object In Java, the type of actual object always determines method calls; object reference type doesn’t play any role in it. You have already used two types of polymorphism (overloading and
overriding) in the previous unit and in the current unit of this block. Now we will look at the third: dynamic method binding. Java uses Dynamic Method Dispatch
mechanism to decide at run time which overridden function will be invoked. Dynamic Method Dispatch mechanism is important because it is used to implement runtime polymorphism in Java. Java uses the principle: “a super class object can refer to a subclass object” to resolve calls to overridden methods at run time.

If a superclass has a method that is overridden by its subclasses, then the different versions of the overridden methods are invoked or executed with the help of a superclass reference variable.

Assume that three subclasses (Cricket_Player Hockey_Player and Football_Player) that derive from Player abstract class are defined with each subclass having its own Play() method.

abstract class Player // class is abstract
{
  private String name;
  public Player(String nm)
  {
    name=nm;
  }
  public String getName() // regular method
  {
     return (name); 

  }


  public abstract void Play();
// abstract method: no implementation
}
class Cricket_Player extends Player
{
  Cricket_Player( String var)
{
}
public void Play()
{
System.out.println("Play Cricket:"+getName());
}
}
class Hockey_Player extends Player
{
Hockey_Player( String var)
{
}
public void Play()
{
System.out.println("Play Hockey:"+getName());
}
}
class Football_Player extends Player
{
Football_Player( String var)
{
}
public void Play()
{
System.out.println("Play Football:"+getName());
}
}
public class PolyDemo
{
public static void main(String[] args)
{
Player ref; // set up var for an Playerl
Cricket_Player aCplayer = new Cricket_Player("Sachin"); // makes specific objects
Hockey_Player aHplayer = new Hockey_Player("Dhanaraj"); Football_Player aFplayer = new Football_Player("Bhutia");
// now reference each as an Animal ref = aCplayer;
ref.Play();
ref = aHplayer;
ref.Play();
ref = aFplayer;
ref.Play();
}
}

Output:

Play Cricket:Sachin

Play Hockey:Dhanaraj

Play Football:Bhutia

Here is the complete solution for question 4 of MCS 024 assignment.

 

IGNOU MCS 024 question 4 solution page 1

 

IGNOU MCS 024 question 4 solution page 2

 

IGNOU MCS 024 question 4 Solution page 3

 

 

IGNOU MCS 024 question 4 Solution page 4

Education4u >> IGNOU AssignmentsMCS 024 Assignment Question 4 Answer - IGNOU MCA

Share on Facebook

PREVIOUS TOPIC
MCS 024 Assignment 2018-19 question 3B and 3C Solution

NEXT TOPIC
2018-2019 IGNOU MCS 024 assignment question 1b solution




SSB Interview Tips.in

©Education4u.co.in