Computer Science, asked by tasmayholkar, 5 months ago

Following code is which type of polymorphism
1. class A
2 1/Some Statements
3}
4 class B extends A
5 l/Some Statements
7 class C extends B{
8 1 / Some Statements
9 )
18
11 public class D{
public static void main(String[] args) {
12
A a = new AO i
a = new BO;
15
a = new CO
)​

Answers

Answered by rishika4466
7

Answer:

(a) class A { public A() { System.out.println("A's no-arg constructor is invoked"); } } class B extends A { } public class C { public static void main(String[] args) { B b = new B(); } } (b) class A { public A(int x) { } } class B extends A { public B() { } } public class C { public static void main(String[] args) { B b = new B(); } }

Answered by Jasleen0599
0

Runtime polymorphism

  • A technique known as runtime polymorphism, commonly referred to as dynamic method dispatch, resolves a call to an overridden method at runtime. The procedure entails using a superclass's reference variable to invoke an overridden method.
  • A technique known as runtime polymorphism, commonly referred to as dynamic method dispatch, resolves a call to an overridden method at runtime. The procedure entails using a superclass's reference variable to invoke an overridden method.
  • The compiler resolves the call in compile-time polymorphism. The compiler does not resolve the call in run-time polymorphism. Additionally known as overloading, early binding, and static binding. It also goes by the names Dynamic binding and Late binding.

JAVA CODE

class A

/Some Statements

}

class B extends A

/Some Statements

class C extends B{

/ Some Statements

)

public class D{

public static void main(String[] args) {

A a = new AO i

a = new BO;

15

a = new CO

)​

#SPJ2

Similar questions