Posts Tagged ‘Java’
Given an integer variable i and a floating-point variable f, that have already been given values, write a statement that writes both of their values to standard output in the following format
LANGUAGE: JAVA CHALLENGE: The exercise instructions here are LONG — please read them all carefully. If you see an internal scrollbar to the right of these instructions, be sure to scroll down to read everything. Given an integer variable i and a floating-point variable f, that have already been given values, write a statement that…
Read MoreAssume the existence of a Widget class that implements the Comparable interface and thus has a compareTo method that accepts an Object parameter and returns an int. Write an efficient static method, getWidgetMatch, that has two parameters.
LANGUAGE: JAVA CHALLENGE: Assume the existence of a Widget class that implements the Comparable interface and thus has a compareTo method that accepts an Object parameter and returns an int. Write an efficient static method, getWidgetMatch, that has two parameters. The first parameter is a reference to a Widget object. The second parameter is a potentially…
Read MoreWrite a program class named SquareDisplay that asks the user for a positive integer no greater than 15.
LANGUAGE: JAVA CHALLENGE: 19. Squares. Write a program class named SquareDisplay that asks the user for a positive integer no greater than 15. The program should then display a square on the screen using the character ‘X’. The number entered by the user will be the length of each side of the square. For example, if…
Read MoreClunker Motors Inc. is recalling all vehicles from model years 2001-2006. A boolean variable named recalled has been declared. Given a variable modelYear write a statement that assigns true to recalled if the value of modelYear falls within the recall range and assigns false otherwise.
LANGUAGE: Java CHALLENGE: Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. A boolean variable named recalled has been declared. Given a variable modelYear write a statement that assigns true to recalled if the value of modelYear falls within the recall range and assigns false otherwise. Do not use an if statement in this…
Read MoreGiven an initialized String variable output , write an expression whose value is a reference to a newly created PrintWriter object associated with a file whose name is contained in output . (Do not concern yourself with any possible exceptions here– assume they are handled elsewhere.)
LANGUAGE: JAVA CHALLENGE: Given an initialized String variable output , write an expression whose value is a reference to a newly created PrintWriter object associated with a file whose name is contained in output . (Do not concern yourself with any possible exceptions here– assume they are handled elsewhere.)
Read MoreDeclare a variable hasPassedTest, and initialize it to true
LANGUAGE: Java CHALLENGE: Declare a variable hasPassedTest, and initialize it to true
Read MoreDeclare two double variables, one named length with a value of 3.5 and the other named width with a value of 1.55
LANGUAGE: Java CHALLENGE: Declare two double variables, one named length with a value of 3.5 and the other named width with a value of 1.55
Read MoreRequired at the end of a declaration, but NOT at the end of an expression
LANGUAGE: Java CHALLENGE: Required at the end of a declaration, but NOT at the end of an expression
Read MoreDeclare an integer value cardsInHand and initialize it to 13
LANGUAGE: Java CHALLENGE: Declare an integer value cardsInHand and initialize it to 13
Read MoreDeclare a character variable named c
LANGUAGE: Java CHALLENGE: Declare a character variable named c
Read MoreWrite a character literal for B in Unicode
LANGUAGE: Java CHALLENGE: Write a character literal for B in Unicode
Read MoreWrite a character literal for A in Unicode
LANGUAGE: Java CHALLENGE: Write a character literal for A in Unicode
Read More