473,498 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java Class

2 New Member
Can you any one help me sove this problem?:
I'm creating a class caled Student that will have the following atrributes:
a) Student ID
b) Last Name
c)First Name
d) Program
The class must have the following methods:
a) A constructor that accepts nothing and intializes all attributes to zero (0) and null accordingly.
b)A Constructor that accepts all values.
c) A method called Display that displays all attributes.
d) A method called changeProgram that changes the program of a student.
c) A main method to test the Dispaly method is the Student class
Apr 30 '07 #1
3 1235
JosAH
11,448 Recognized Expert MVP
Sure we can help you. What's the part you're having problems with?

kind regards,

Jos
Apr 30 '07 #2
debajjio
2 New Member
Sure we can help you. What's the part you're having problems with?

kind regards,

Jos
Thanks for helping me out....
After creating the classes the above classes...I don't have any idea on how to apply the following methods to them...:
a) A constructor that accepts nothing and intializes all attributes to zero (0) and null accordingly.
b)A Constructor that accepts all values.
I so confused any help will be welcome.
May 1 '07 #3
JosAH
11,448 Recognized Expert MVP
Thanks for helping me out....
After creating the classes the above classes...I don't have any idea on how to apply the following methods to them...:
a) A constructor that accepts nothing and intializes all attributes to zero (0) and null accordingly.
b)A Constructor that accepts all values.
I so confused any help will be welcome.
Well, simply create the class according to those specs then:
Expand|Select|Wrap|Line Numbers
  1. public class Student {
  2.  
  3.    // all members are initialized to null, 0 etc.
  4.    private String ID;
  5.    private String lastName;
  6.    private String firstName;
  7.    private String program;
  8.    // a: so this ctor has got nothing to do:
  9.    public Student() { }
  10.    // b: this ctor sets all members:
  11.    public Student(String ID, String lastName, String firstName, String program) {
  12.       this.ID= ID;
  13.       // same for the other members
  14.    }
  15.    // c: display the String representation of this object
  16.    public void Display() {
  17.       System.out.print(this);
  18.    }
  19.    // d: also according to the requirements:
  20.    public String changeProgram(String program) {
  21.       String oldProgram= this.program;
  22.       this.program= program;
  23.       return oldProgram; // convenience
  24.    }
  25.    public String toString() {
  26.       // return a String representation of this object
  27.    }
  28. }
That's about it; fill in the blanks and voila.

kind regards,

Jos
May 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
167058
by: Lem | last post by:
I get the error Exception in thread "main" java.lang.NoClassDefFoundError when I type java app2 in the command prompt. I've tried moving to the jre directory and typed java c:\app2\app2, but it...
2
9196
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
0
5638
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
1
9582
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
2
6918
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
15
2767
by: Xah Lee | last post by:
On Java's Interface Xah Lee, 20050223 In Java the language, there's this a keyword “interface”. In a functional language, a function can be specified by its name and parameter specs....
1
3855
by: aapexclient | last post by:
I have a problem with Java finding my custom class directory. I have searched the forums and tried everything, but nothing seems to work. The <javapgm>.java compiled cleanly and created...
5
6256
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
0
3874
by: r035198x | last post by:
Inheritance We have already covered one important concept of object-oriented programming, namely encapsulation, in the previous article. These articles are not articles on object oriented...
0
7126
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7005
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7381
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5465
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
4916
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1424
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
293
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.