Menu
Question Index
...

Write a program to print the available constructors and signatures of the class of the given object.

Input (Object) Printed Output
A A()
A(int, int)
B B()
B(int, int, int)
C C()
C(java.lang.String, java.lang.String)
C(double, float)
D D()
D(boolean, boolean)
D(int, int)


import java.lang.reflect.*;

class PrintCurrentClassConstructors
{
    public static void main(String s[])
    {
        D d = new D();
        System.out.println("The constructors in class A are :\n");
        printConstructorNames(d);

    }


    public static void printConstructorNames(Object object) {
    }

}
class A {

public A() {
}

public A(int a, int b) {
}

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 {

public B() {
}

public B(int a, int b, int c) {
}

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

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

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

class C {

public C() {
}

public C(String name, String cityName) {
}

public C(double a, float b) {
}

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 {

public D() {
}

D(boolean a, boolean b) {
}

public 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