Menu
Question Index
...


Given the java bean, write a program to find the missing getter and setter methods. Note that you need to use reflection api to do this. The fields should be sorted by name. If it is boolean datatype, you need to use 'is' instead of 'get'.

Input (Object) Output (String)
new Student() getName
setName
setPercentage
getSection
new Employee() getDesignation
setDesignation
isGender
setGender
new Mobile() setMemory
getPixel
setPixel
getResolution
new College() getAddress
setAddress
getCollegeCode
setCollegeCode
getCollegeName
setCollegeName
getStudents
setStudents

class FindMissingMethods

{    public static void main(String s[])
    {
        Student student = new Student();
        String result = findMissingMethods(student);
        System.out.println(result);

    }


public static String findMissingMethods(Object object) {
//Write code here to find the missing getters and setters
}

//If required write any additional methods here
}
class Student {

String name;
boolean gender;
int marks;
double percentage;
char section;
int id;

public boolean isGender() {
return gender;
}

public void setGender(boolean gender) {
this.gender = gender;
}

public int getMarks() {
return marks;
}

public void setMarks(int marks) {
this.marks = marks;
}

public double getPercentage() {
return percentage;
}

public void setSection(char section) {
this.section = section;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}
}

class Employee {

double salary;
String name;
String designation;
boolean gender;

public double getSalary() {
return salary;
}

public void setSalary(double salary) {
this.salary = salary;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}

class Mobile {

String companyName;
String modelName;
double price;
double memory;
float pixel;
int resolution;

public String getCompanyName() {
return companyName;
}

public void setCompanyName(String companyName) {
this.companyName = companyName;
}

public String getModelName() {
return modelName;
}

public void setModelName(String modelName) {
this.modelName = modelName;
}

public double getPrice() {
return price;
}

public void setPrice(double price) {
this.price = price;
}

public double getMemory() {
return memory;
}

public void setResolution(int resolution) {
this.resolution = resolution;
}
}

class College {

int students;
String collegeCode;
String address;
String collegeName;
}

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