• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/22

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

22 Cards in this Set

  • Front
  • Back

Write the code for invoking a method named sendSignal. There are no arguments for this method .Assume that sendSignal is defined in the same class that calls it.

sendSignal();

printTodaysDate is a method that accepts no arguments and returns no value . Write a statement that calls printTodaysDate.Assume that printTodaysDate is defined in the same class that calls it.

printTodaysDate();

Write the code for invoking a method named sendObject. There is one argument for this method which is of type Customer.




Assume that there is a reference to an object of type Customer, in a variable called John_Doe.




Use this reference as your argument .Assume that sendObject is defined in the same class that calls it.

sendObject(John_Doe);

Write the code for invoking a method named sendNumber . There is one int argument for this method . Send the number 5 as an argument to this method .




Assume that sendNumber is defined in the same class that calls it.

sendNumber(5);

Write the code for invoking a method named sendVariable. There is one int argument for this method .




Assume that an int variable called x has already been declared and initialized to some value .




Use this variable 's value as an argument in your method invocation.Assume that sendVariable is defined in the same class that calls it.

sendVariable(x);

Write the code for invoking a method named sendTwo.




There are two arguments for this method :


a double and an int .




Invoke the method with the double value of 15.955 and the int value of 133.Assume that sendTwo is defined in the same class that calls it.

sendTwo(15.955,133);

printErrorDescription is a method that accepts one int argument and returns no value .




Write a statement that invokes the method printErrorDescription, passing it the value 14.




Assume that printErrorDescription is defined in the same class that calls it.

printErrorDescription(14);

printLarger is a method that accepts two int arguments and returns no value .




Two int variables , sales1 and sales2, have already been declared and initialized .




Write a statement that calls printLarger, passing it sales1 and sales2.




Assume that printLarger is defined in the same class that calls it.

printLarger(sales1, sales2);

add is a method that accepts two int arguments and returns their sum .




Two int variables , euroSales and asiaSales, have already been declared and initialized .




Another int variable , eurasiaSales, has already been declared .




Write a statement that calls add to compute the sum of euroSales and asiaSales and that stores this value in eurasiaSales.




Assume that add is defined in the same class that calls it.

eurasiaSales = add(euroSales, asiaSales);

toThePowerOf is a method that accepts two int arguments and returns the value of the first parameter raised to the power of the second.




An int variable cubeSide has already been declared and initialized .




Another int variable , cubeVolume, has already been declared .




Write a statement that calls toThePowerOf to compute the value of cubeSide raised to the power of 3 and that stores this value in cubeVolume.




Assume that toThePowerOf is defined in the same class that calls it.

cubeVolume = toThePowerOf(cubeSide, 3);

Assume that x is a variable that has been declared as an int and been given a value .




Assume that twice is a method (in the same class as the caller) that receives a single integer parameter and returns twice its value . (So if you pass 7 to twice it will return 14. Thus the expression twice(7) has the value 14.




Write an expression whose value is eight times that of x without using the standard Java arithmetic operators (*,+, etc.). Instead, use calls to twice to accomplish this.




In this exercise you must write this as a single expression -- you must not write any statements . Also, you may only use the twice() function-- no other functions or operators .

twice(twice(twice(x)))

Assume that x is a variable that has been declared as an int and been given a value . Assume that oneMore is a function that receives a single integer parameter and returns a value that is one greater than its argument . (So if you pass 7 to oneMore it will return 8. Thus, the expression oneMore(9) has the value 10.




Write an expression whose value is four more than x without using the standard Java arithmetic operators (*,+, etc.). Instead, use calls to oneMore to accomplish this.




In this exercise you must write this as a single expression -- you must not write any statements . Also, you may only use the oneMore function-- no other functions or operators .

oneMore(oneMore(oneMore(oneMore(x))))

max is a method that accepts two int arguments and returns the value of the larger one.




Two int variables , population1 and population2, have already been declared and initialized .




Write an expression (not a statement !) whose value is the larger of population1 and population2 by calling max.




Assume that max is defined in the same class that calls it.

max(population1, population2)

max is a method that accepts two int arguments and returns the value of the larger one.




Four int variables , population1, population2, population3, and population4 have already been declared and initialized .




Write an expression (not a statement !) whose value is the largest of population1, population2, population3, and population4 by calling max.




Assume that max is defined in the same class that calls it.

max((max(population1, population2)), (max(population3, population4)))

Write the definition of a method twice, which receives an integer parameter and returns an integer that is twice the value of the parameter

public static int twice(int a) {


int b = 2 * a;


return b;


}

Write the definition of a method add, which receives two integer parameters and returns their sum .

public static int add(int a, int b) {


int c = a + b;


return c;


}

Write the definition of a method powerTo, which receives two parameters . The first is a double and the second is an int . The method returns a double .




If the second parameter is negative, the method returns zero. Otherwise it returns the value of the first parameter raised to the power of the second parameter .



Given that a method receives three parameters a, b, c, of type double , write some code, to be included as part of the method , that determines whether the value of "b squared" – 4ac is negative. If negative, the code prints out the message "no real solutions" and returns from the method

if (b*b < 4*a*c) System.out.println("no real solutions");

Write the definition of a method printDottedLine, which has no parameters and doesn't return anything. The method prints to standard output a single line (terminated by a newline) consisting of five periods.

void printDottedLine() {


System.out.println(".....");


}

Write the definition of a method printGrade, which has a char parameter and returns nothing. The method prints on a line by itself the message string Grade: followed by the char parameter (printed as a character ) to standard output . Don't forget to put a new line character at the end of your line.

public static void printGrade(char x) {


System.out.println("Grade: " + x);


}

Write a method max that has two string parameters and returns the larger of the two.



Write a method min that has three string parameters and returns the smallest.