Becky Miller

Greenhorn
+ Follow
since Jan 24, 2001
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Becky Miller

I need to write a program to generate a random sequence of capital letters that does not include vowels.

So far I only have this

public class Letters{
public static void main(String [] args)
{
symbol= (char)(26.0 * Math.random());
}
}
can anyone help?
21 years ago
Brett,
An instance variable is a variable that is associated with a particular object , each instance of the class will have its own copy of each of these variables.
A member variable is associated with the class, and is shared by all objects of the class. It is also referred to as class variable because the variable belongs to the class, not to any particular object.
here's an example I found:
public class Sphere
{

// class variable
static double PI = 3.14;

//instance variables
double xCenter;
double yCenter;
double zCenter;
double radius;
}

21 years ago
I am trying to write a program that requires the program to select six different numbers from integers 1 to 49 and then generate five sets of entries.
so far I have :
public class Lottery{
public static void main(String [] args)
{


int number =0;
number = 1 +(int)(49 * Math.random());
System.out.println(number);

}
}
how do you select 6 random numbers from 1 to 49?
I really don't know where to go from here. Any help would be appreciated.
21 years ago
What's the difference b/w reserved word and keyword?
Ex:
Which two are reserved words in Java?
a)run
b)default
c)implement
d)import
21 years ago
so its passing the value 1 into change_i(i)
--------------------------------------------
why does this code print 4?
public class example{
int i[] ={0};
public static void main(String args[]){
int i[] = {i};
change_i(i);
System.out.println(i[0]);
}
public static void change_i(int i[]) {
i[0] = 2;
i[0] *= 2;
}
}
21 years ago
I have some codes that I don't understand. This is just one of them.
public class example{
int i =0;
public static void main(String args[]) {
int i = 1;
change_i(i);
System.out.println(i);
}
public static void chagne_i(int i) {
i = 2;
i *= 2;
}
}
the program prints 1 but how. I thought it would be 4.
21 years ago
can somebody explain how to get the answer to this program
Thanks.
public class test {
public static void main(String args[]){
int x,y;
x = 3 & 5;
y = 3 | 5;
System.out.println(x +" " +y);
}
}
21 years ago
Ryan,
okay, I think I finally got it now. ObjectX.setx(10) calls the method setx and passes the value 10 into the method and sets the x variable in object ObjectX to 10. This object and method concepts are hard to grasp.
21 years ago
Kavya,
so this method sets a variable x to newX, then passes that value with the code (int newX)?
public void setx(int newX){
x= newX;
}
21 years ago
can anyone explain this code step by step:
specifically the methods

class AnIntegerNameX
int x;
public int x(){
return x;
}
public void setx(int newX){
x= newX;
}
}
21 years ago
I thought that
Pass p = new Pass();
is creating the object, so how could this be a constructor?
21 years ago
In this code Pass is creating an object new Pass, so how come there's no constructor to initialize the object? Thanks.
public class Pass{
static int j=20;
public static void main(String args[]){
int i =10;
Pass p = new Pass();
p.amethod(i);
System.out.println(i);
System.out.println(j);
}
public void amethod(intx){
x = x*2;
j = j*2;
}
}

21 years ago
so the "this" keyword is used to access the instance variables:
public int x = 0;
public int y = 0;
and not the constructors parameters.
21 years ago
do you need to know how to convert from decimal to binary for the certification exam?
b/c I came across this code
int i =8;
i >>=2;
the value of i is 2 but I don't know how to get this.
21 years ago
One thing about constructors, first you have to create the object then you need a constructor to use the object that you created, right?

for example:
// object
Point origin_one = new Point(23, 94);
public class Point {
public int x = 0;
public int y = 0;
//A constructor!
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
But why do you use this dot with the this keyword?
21 years ago