Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


I need Help On a test!



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
Confused



Joined: 26 Feb 2007
Posts: 2

PostPosted: Mon Feb 26, 2007 3:58 am    Post subject: I need Help On a test! Reply with quote

I'm just learning java and my teacer likes giving us tests on stuff he never taught us... I'm not asking for you to give me ther answers but just at least explain what this stuff means

he gave us a program then 16 questions about it

All I know is that the prgram is a class that takes students names and test scores and finds there averges and studd like that

ok heres the program

// Solution 5.1

/* Student.java
Manage a student's name and three test scores.
*/
public class Student {

//Instance variables
//Each student object has a name and three test scores
private String name; //Student name
private int test1; //Score on test 1
private int test2; //Score on test 2
private int test3; //Score on test 3

// Default constructor -- initialize name to the empty string and
// the test scores to zero
public Student() {
name = "";
test1 = 0;
test2 = 0;
test3 = 0;
}

//Aditional constructor -- initialize the name and test scores
//to the values provided
public Student(String nm, int t1, int t2, int t3){
name = nm;
test1 = t1;
test2 = t2;
test3 = t3;
}

//Aditional constructor -- initialize the name and test scores
//to match those in perameter s.
public Student(Student s){
name = s.name;
test1 = s.test1;
test2 = s.test2;
test3 = s.test3;
}

//Other Methods

public void setName (String nm){
//Set a students name
name = nm;
}

public String getName(){
//Get a students name
return name;
}

public void setScore (int i, int score){
//Set test i to score
if (i == 1) test1 = score;
else if (i == 2) test2 = score;
else test3 = score;
}

public int getScore (int i){
//retrieve score i
if (i == 1) return test1;
else if (i == 2) return test2;
else return tes3;
}

public int getAverage(){
//compute and return the average
int average;
average = (int) Math.round((test1 + test2 + test3) / 3.0);
return average
}

public int getHighscore(){
//determine and return the highest score
int highScore;
highscore = test1;
if (test2 > highscore) highscore = test 2;
if (test3 > highscore) highscore = test 3;
return highscore;
}

public String toString(){
//Construct and return a string representation of the student
string str;
str = "Name: " + name + "\n" + // "\n" denotes a newline
"Test 1: " + test1 + "\n" +
"Test 2: " + test2 + "\n" +
"Test 3: " + test3 + "\n" +
"Average: " + getAverage();
return string;
}
}

________________________________________________________

Ok so theres the prgram the Questions are:

1. Identify the four structural elements of the student class prgram


2. Why did I omit the clause extends <some class> in my program


3. Explain Class hierarchy


4. Why are instance variables always declared to be private


5. What would happen if I declared them public


6. What happens if I omit it completely


7. Identify the instance variables in student class program


8. What does the constructor method do in the student class


9. Why didn't I declare and intalize my variables at the same time


10. Why do I use so many comments in this program
(I actually know the answer to this one)

11. Why do I need a default constructor
(what the crap is a constructor?)

12. Why did I provide additional constructors


13. In Additional constructor section, explain the following code:

name = "";

name = nm;

14. Explain Chaining and where did I place it in the student class program


15. List 2 visibility modifiers in this program


16 Rewrite the student class to exclude the "\n" in t the toString section


And that is it. I seriously don't know what any of those questions mean PLEASE HELP!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap