Question: inherittance



Share on Google+Share on Google+

1 Answer(s)      5 years and 9 months ago
Posted in : Java Server Faces Questions

Develop a class Borrower which has 5 important fileds, namely borrowerId, borrowerName, borrowerLastName, contactNumber and dateOfBirth. Your class must demonstrate good encapsulation where all fileds get manipulated through get and set methods. Save your file as

Sample input

The borrower class is instantiated four times using the following sample data:

borrowerId[10420040, 10420041, 10420042, 10420043]

borrowerName[David, Mike, Steve, Finsen]

borrowerLastName[Desalt, Smith, Sugars, Lions]

contactNumber[7820001, 1209111,8912100,79910211]

dateOfBirth[1990-11-01, 1981-12-12, 1991-22-03, 1980-10-02]

The program should allow the system administrator to search for a certain borrower in the class by inputing the borrower's ID in the input screen & return the search results on a message dialog box.

View Answers

August 18, 2011 at 4:36 PM

import java.util.Scanner;
import java.util.ArrayList;
class Borrower{
    int borrowerId;
    String borrowerName;
    String borrowerLastName;
    long contactNumber;
    String dateOfBirth;

    Borrower(int borrowerId,String borrowerName,String borrowerLastName,long contactNumber,String dateOfBirth){
    this.borrowerId= borrowerId;
    public int getBorrowerId(){
        return borrowerId;
    public String getBorrowerName(){
        return borrowerName;
    public String getBorrowerLastName(){
        return borrowerLastName;
    public long getContactNumber(){
        return contactNumber;
    public String getDateOfBirth(){
        return dateOfBirth;

    public static void main(String[] args){
        Scanner input=new Scanner(;
    ArrayList<Borrower> list=new ArrayList<Borrower>();
    Borrower b1=new Borrower(10420040,"David","Desalt",7820001,"1990-11-01");
    Borrower b2=new Borrower(10420041,"Mike","Smith",1209111,"1981-12-12");
    Borrower b3=new Borrower(10420042,"Steve","Sugars",8912100,"1991-22-03");
    Borrower b4=new Borrower(10420043,"Finsen","Lions",79910211,"1980-10-02");
System.out.println(" ");
System.out.print("Enter Id to search: ");
int id = input.nextInt();
for(Borrower b : list){
if(id == b.getBorrowerId())
System.out.print("Name is: "+b.getBorrowerName()+"\nLast Name is: "+b.getBorrowerLastName()+"\nContact No is: " +b.getContactNumber()+"\nDate of Birth is: "+b.getDateOfBirth());


Related Tutorials/Questions & Answers:
Java Spring Hibernate Struts Training i have an ques. of advanced java commandlink tag in primefaces needs onclick effect how can i run ASP.Net Server from netbeans IDE? java code for cursor java vertual machine launcher error; cannot access jarfiles JSF Tutorial render in input typetext java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener After authentication and connection establishment, Upload a zipfile by chunks in java JSF CONNECTION WITH MICROSOFT ACCESS Download Current Web Page As PDF java servlet dropdown list in jsf panelGrid header do the following how to make drop down list in JSF & fetch data Item from database help me please doubt regarding JSF Creating Dynamic Tree How to upload zip file from android to server programmatically????? jsf application war file not running in my jboss 6.0 on linux 5.5 Business analysis servlet servlet exception in thread main while running servlet How to get browser time zone? JAVA Socket Programming excel report fro jsp mysql Redirect to same jsp page on successful login jsf f:parm value dynamical settings jsf f:parm value dynamical settings RMI Program in netbeans pagination in jsf pagination jsf pagination How create csv format in jsf ? need JSP Code. Arrays, loops and string handling unique value renderer JSF 1.2 online tutorial JSF code JSP jps Multicast under UDP(client server application) How to rectify "Bad version number in .class file" exception in Eclipse about avl tree and hashing project on avl tree and hashing How to navigate from one jsf to another in eclipse how to focus on the new window opened from JSF ? Editing UI components using managed bean


Advertisement null