Java Challenge

 Forum:   Subject:  View:  

 

 Blue Pelican Site
 Login/Edit Account


 Forgot your password?

     (Page 1 of 2)
    1 2  Nxt>  

Topic: Making it print
ID: Author, Blue Pelican Java Date/Time: 06/30/2006 3:35:45 PM
Message:
Suppose you have a Class called MyClass and that you have created object obj from it. Futhermore, suppose that MyClass has a state variable called var1. What method would you add to MyClass in order that   System.out.println(obj);  print the value of obj.var1 enclosed in a set of square brackets. Be sure to not only give the name of the method but to give the code inside it.
Reply Title: Override toString()  
ID: Binary To Hex Date/Time: 08/01/2006 7:28:48 AM
Message:
//I believe this is what you want.
public String toString() {
   return ("[" + var1 + "]");
}
Reply Title: You got it!  
ID: Author, Blue Pelican Java Date/Time: 08/01/2006 10:19:27 AM
Message:
This is exactly correct... creating a toString method. Incidentally, did you notice the drop-down at the top of the page that lets you access questions in other lessons (a few have no questions yet).

Topic: What would you use?
ID: Author, Blue Pelican Java Date/Time: 07/01/2006 8:17:50 AM
Message:
Suppose you need to calculate something complicated like tan(x*x + log(sin(x)). Instead of calculating these values directly in real time, what data structure would you use to give answers to pre-computed values of this function using x ranging as integer values from 1 to 450?
Reply Title: very simple  
ID: wiz girl Date/Time: 02/19/2007 2:36:05 AM
Message:
class abc
{
public void xyz(int x)
{
double i,j,k,l,m;
k=x*x;
l=Math.sin(x);
j=Math.log(l);
m=k+j;
i=Math.tan(m);
System.out.println(i);
}}

this will surely yield ur answer u can also input x from the user
Reply Title: maybe  
ID: Big Knee Date/Time: 02/19/2007 1:17:09 PM
Message:
that would output the right answer, but it still doesn't solve the time complexity problem. something that would help would be using a look-up table. if you know ahead of time which logs and trig functions you will need, you can store them in a table and look them up as you go  instead of working them each time. this would prove to run a bit quicker.

Topic: Good or bad?
ID: Author, Blue Pelican Java Date/Time: 07/01/2006 8:18:57 AM
Message:
In hash tables is clustering a good or bad thing?

Topic: The ways
ID: Author, Blue Pelican Java Date/Time: 07/01/2006 8:19:51 AM
Message:
Name the two ways of handling collisions.

Topic: Figure of merit?
ID: Author, Blue Pelican Java Date/Time: 07/01/2006 8:20:35 AM
Message:
What is a figure of merit for a hash table?

Topic: Faster?
ID: Author, Blue Pelican Java Date/Time: 07/01/2006 8:21:32 AM
Message:
Which is typically faster, finding data in a look-up table or a hash table?

Topic: Buckets?
ID: Author, Blue Pelican Java Date/Time: 07/01/2006 8:25:02 AM
Message:
Suppose the keys of a hash tablew are to be stored in the array created by:

     int key[] = new int[2000];

How many buckets does this table have?

Topic: Load factor
ID: Author, Blue Pelican Java Date/Time: 07/01/2006 8:26:02 AM
Message:
If 200 items are stored in the hash table of the previous problem, what is the load factor?

(Page 1 of 2)             1   2   NextPage>>  

This Forum automated by software from bluepelicanjava.com