java Test UPDATED ACTUAL Exam Questions and CORRECT
Answers
How many parameters for: Public void compare(int x, int y, int z);
Public void go(); - Write a method signature for "go" that does not have parameters nor returns a
value
public int process (); - Write a method signature for "process" with parameters and returns a
value of type "int"
Play(); - Write a method call for "play"
if(isTouching(worm.class)
{
RemoveTouching(worm.class)
} - Write an if statement that does something to a crab
Allows access to methods of a class. We use it to change the image of a class - What is a dot
notation? and when do we use it?
Turn(Greenfoot.getRandomNumber(49); - Write a method call that will return an integer
between 0 and 49
if(Greenfoot.getRandomNumber(100)(31)
{
turnGreenfoot.getRandomNumber(17)(31);
} - Write an if statement that turns 17 degrees, but only 31 percent of the time
, if(Greenfoot.getRandomNumber(14)
{
*something*
} - Write an if statement that turns an object a random number of degrees between 0 and 14
if(Greenfoot.getRandomNumber(20)(-20)
{
turn(3);
} - Write an if statement that turns an object a random number of degrees between -20 and 20
== != > < <= >= - Write the symbols for 6 different comparisons operators
Actor - What class is Worm a subclass of?
Helps another cass look for the worm to eat it. - What is the rationale behind making a separate
method called "lookForWorm"?
Needs a capital "p" - What is wrong with naming a class in Greenfoot "pig"?
Comments are notes that don't effect your coding - What is a comment?
-Allows us to edit later on
- Help us remember something we might forget - Why do we use comment sin our programs?
// = Single line comment
/*comment*/ = multi-line comment - Write two different types of comments below and what
their use is
Answers
How many parameters for: Public void compare(int x, int y, int z);
Public void go(); - Write a method signature for "go" that does not have parameters nor returns a
value
public int process (); - Write a method signature for "process" with parameters and returns a
value of type "int"
Play(); - Write a method call for "play"
if(isTouching(worm.class)
{
RemoveTouching(worm.class)
} - Write an if statement that does something to a crab
Allows access to methods of a class. We use it to change the image of a class - What is a dot
notation? and when do we use it?
Turn(Greenfoot.getRandomNumber(49); - Write a method call that will return an integer
between 0 and 49
if(Greenfoot.getRandomNumber(100)(31)
{
turnGreenfoot.getRandomNumber(17)(31);
} - Write an if statement that turns 17 degrees, but only 31 percent of the time
, if(Greenfoot.getRandomNumber(14)
{
*something*
} - Write an if statement that turns an object a random number of degrees between 0 and 14
if(Greenfoot.getRandomNumber(20)(-20)
{
turn(3);
} - Write an if statement that turns an object a random number of degrees between -20 and 20
== != > < <= >= - Write the symbols for 6 different comparisons operators
Actor - What class is Worm a subclass of?
Helps another cass look for the worm to eat it. - What is the rationale behind making a separate
method called "lookForWorm"?
Needs a capital "p" - What is wrong with naming a class in Greenfoot "pig"?
Comments are notes that don't effect your coding - What is a comment?
-Allows us to edit later on
- Help us remember something we might forget - Why do we use comment sin our programs?
// = Single line comment
/*comment*/ = multi-line comment - Write two different types of comments below and what
their use is