Menu
Question Index
...

Write a program to print the methods in the current class. The method names should be in sorted order.

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


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

    }


    public static void printMethodNames(Object object) {
    }

}
class A {

A() {
}

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

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

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";
}
}

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