Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Show the output of the following programs. Program 1 public class Test { public static void main( String[] args ){ A a = new A(

Show the output of the following programs.

Program 1

public class Test {

public static void main(String[] args){

A a = new A();

a.p(10);

a.p(10.0);

}

}

class B {

public void p(double i) {

System.out.println(i * 2);

}

}

class A extends B {

// This method overrides the method in B

public void p(double i) {

System.out.println(i);

}

}

Program 2

public class Test {

public static void main(String[] args){

A a = new A();

a.p(10);

a.p(10.0);

}

}

class B {

public void p(double i) {

System.out.println(i * 2);

}

}

class A extends B {

// This method overloads the method in B

public void p(int i) {

System.out.println(i);

}

}

Show the output of the following programs.

public class Faculty extends Employee {

public static void main(String[] args) {

new Employee();

}

public Faculty() {

super();

System.out.println("Faculty's no-arg constructor is invoked");

}

}

class Employee extends Person {

public Employee() {

super("Invoke Persons overloaded constructor");

System.out.println("Employee's no-arg constructor is invoked");

}

}

class Person {

public Person () {

System.out.println("Person's no-arg constructor is invoked");

}

public Person (String s) {

this();

System.out.println(s);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

General Purpose of Your Speech Analyzing Your Audience

Answered: 1 week ago

Question

Ethical Speaking: Taking Responsibility for Your Speech?

Answered: 1 week ago