The Artima Developer Community
Sponsored Link

Java Answers Forum
program that create objects of the class, & use the methods of the class

1 reply on 1 page. Most recent reply: Dec 5, 2005 11:09 PM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
colin kass

Posts: 1
Nickname: kodza
Registered: Dec, 2005

program that create objects of the class, & use the methods of the class Posted: Dec 5, 2005 12:32 PM
Reply to this message Reply
Advertisement
I am trying to write some programs to answer the questions at the bottom of these descriptions of classes.

I have downloaded a class that has two attributes, all of the type int, and four methods. (attribute1 & attribute2) The class has two constructors. The first constructor receives no parameters, and assigns certain fixed initial values to the attributes. The second constructor receives a double as a parameter. It too assigns values to the attributes, but not necessarily the same values as assigned by the first constructor.

The four methods are described as:

method1
This method takes no parameters, and returns the value of attribute1.

method2
This method takes an int as a parameter, and returns the value of this parameter added to attribute2.

method3
There are two versions of this method. The first version takes one parameter, an int. The second also takes one parameter, a char. Neither versions return a value.

method4
This method takes no parameters, and returns an array of Strings. Every element in the array is filled.

Questions
1. What is the initial value of attribute1 when an object is created using the first constructor?

2. What is the initial value of attribute2 when an object is created using the first constructor?

3. What is the initial value of attribute1 when an object is created using the second constructor?

4. What is the initial value of attribute2 when an object is created using the second constructor?

5. What happens when you call method3 with an int as parameter?

6. What happens when you call method3 with a char as parameter?

7. What is the length of the array returned by method4?


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: program that create objects of the class, & use the methods of the clas Posted: Dec 5, 2005 11:09 PM
Reply to this message Reply
How can I read a programmer's mind?
Your teachetr obviously expects you to actually run the program to get these answers.
There is no way to tell you which values the attributes have or what the methods do, since we don't have the program.

I know you are too lazy to do your homework, but at least try to actually read the questions before posting them here.
You would have saved some time then.

Flat View: This topic has 1 reply on 1 page
Topic: NullPointerException Previous Topic   Next Topic Topic: Help Cleaning Code

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use