Menu
Question Index
...

Write a program to check if a class has a constructor with the given parameters.

Input (Object, Object[]) Output (String)
new Student(), {101, 989} true
new Student(), {109, 960, 96.00, 'A'} true
new Student(), {} true
new Student(), {"Srujan", 590, 59.00, 'D'} false
new Employee(), {"Ramesh", 20000.0, "Programmer", true} true
new Employee(), {"Ramesh", 20000.0} true
new Employee(), {} true
new Employee(), {"Mohan", true} false


import java.lang.reflect.*;
import java.util.*;
class HasRelevantConstructor
{
    public static void main(String s[])
    {
        Student student = new Student();
        Object parameters[] = {101, 989};
        boolean valid = hasConstructor(student, parameters);
        System.out.println(valid);

    }


    public static boolean hasConstructor(Object object, Object[] parameters) {
    }

}
class Student {

public Student(Integer id, Integer marks) {
}

public Student(Integer id, Integer marks, Double percentage, Character section) {
}

public Student() {
}
}

class Employee {

public Employee(String name, Double salary) {
}

public Employee(String name, Double salary, String designation, Boolean gender) {
}

public Employee() {
}
}

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