473,624 Members | 2,543 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 1251
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
167095
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 gives me the same exception. What could be the problem? Thanks in advance, Lem
2
9217
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 problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
0
5649
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 connect to the DB I get the following exception at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2120)
1
9623
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
2
6944
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 attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
15
2782
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. For example: f(3) f(3, )
1
3863
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 <javapgm>.class. Error message is: Warning: java.lang.ClassNotFoundException: javapgm Versions of software: Apache 2.0.59(Win32) PHP 4.4.4 Java 1.5.0_01 Windows 2000 5.0
5
6273
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 JDK 6 downloadable from http://java.sun.com/javase/downloads/index.jsp. I will be using JDK 5(update 8)
0
3888
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 programming but on Java programming but I will cover all the important aspects of object oriented programming as Java has full support for object-oriented programming even though it is not a fully object-oriented language (in the sense that you can write...
0
8249
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8493
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6112
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.