Menu
Question Index
...

Write a program to print the method names which are declared in the current and all its super classes expect Object. The method names should be sorted.

Input (Object) Output (String)
new A() add
div
mul
new B() add
div
getFirstName
getName
mergeStrings
mul
new C() distance
isFound
isValid
new D() add
div
getFirstName
getName
mergeStrings
mul
relation
speed
new E() EMPTY


import java.lang.reflect.*;
import java.util.*;
class PrintAllClassMethods
{
    public static void main(String s[])
    {
        D d = new D();
        System.out.println("The methods in class D are : ");
        printMethodNames(d);

    }


    public static void printMethodNames(Object object) {
    }

}
class A {

A() {
}

public int mul(int a, int b, int c) {
return 5;
}

public void add(int a, int b) {
}

public double div(double a, double b) {
return 2.5;
}
}

class B extends A {

B() {
}

public String getName() {
return "Cerone";
}

public String getFirstName(String fullName) {
return "MC";
}

public void mergeStrings(String a, String b) {
}
}

class C {

C() {
}

public float distance(float c, float d, float e) {
return 1.2f;
}

public boolean isFound() {
return true;
}

public boolean isValid(boolean k) {
return false;
}
}

class D extends B {

D() {
}

D(int a, int c) {
}

public void speed(int time, int distance) {
}

public String relation(String person1, String person2) {
return "brother";
}
}

class E {
}

Doubts

Problems

Topic: Java Regular Expression

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App