Share on Google+Share on Google+

1 Answer(s)      7 years ago
Posted in : Java Beginners
View Answers

October 12, 2009 at 1:00 PM

Hi Friend,

Try the following code:

import java.util.*;

public class Person
int matricNo;
String name;
String date;
String gender;
public Person(int matricNo,String name,String date,String gender){
public void setMatricNo(int matricNo){
public int getMatricNo(){
return matricNo;

public void setString(String name){
public String getName(){
return name;

public void setDate(String date){
public String getDate(){
return date;

public void setGender(String gender){
public String getGender(){
return gender;
public static void main(String args[]){
System.out.println("Enter Matric No");
Scanner input=new Scanner(;
int no=input.nextInt();
System.out.println("Enter Name");
System.out.println("Enter Date of Birth in format MM-dd-yyyy");
String ;
System.out.println("Enter Gender");
Person person=new Person(no,n,dob,g);
int mNo=person.getMatricNo();
String personName=person.getName();
String dateB=person.getDate();
String gen=person.getGender();
System.out.println(mNo+" "+personName+" "+dateB+" "+gen);



Related Tutorials/Questions & Answers: - Java Beginners  Write a class called that has instance variables matric number, name, date of birth, and gender. Use appropriate data types for these instance variables. Include constructor and set and get methods
How to integrate core java with Hibernate
Hibernate Example. Index.jsp Web.xml
servlet javabean - JSP-Servlet
servlet javabean  how to use a java bean in servelts .plese give me one example program using servelt mvc concept.  Hi Friend, Try the following code: 1) public class Person { private String name
Wiring References To List Element
; } } This class contains the name of the person. package
SPEL-Wiring Null
; } } This class contains the name of the person. package
Hibernate saveOrUpdate Method
and then created a POJO / Persistent class named to fetch... : package; public class Person { private int id
Use Java Bean In Servlets
. Here is the code of public class Person { private String name
Spring Validation
. package com.roseindia; public class Person { private
Calling Methods Using SpEL
by calling methods. The Person class contains property named "
JPA One-to-One Relationship
; Model Class: /** *  */ package
Hibernate 4 Annotation Example using the Annotations (may be called Entity class). package
Why this is not working...?
and files.   public class Person { private String name
Dirty Checking In Hibernate
the Java Application Directory Structure package net.roseindia
Hibernate SessionFactory
inside the <property> sub tag of <session-factory> tag.
Hibernate 4 Annotations Tutorial
: Here is the code of Entity class ( package net.roseindia
First Hibernate Application
-configuration> Step 6 : Created a POJO class (persistent class) named