1. Java class definition.
A Java class definition contains an object’s and .
public Class MyClass
.MyClass
isn’t descriptive enough.Class
is not a keyword. the keyword class
starts with a lowercase characterinit()
header as public vid init()
.vid
is not a keyword understood by the compilerSystem.out.println("***");
.println()
statement.println()
prints.n
and m
have been initialized as numeric data types. Calculate the sum of the two numbers as n - m
.n
and m
will be calculated instead of the sum.Test.java
. Describe the compilation and execution process for this program, naming any other files that would be created.0. Print N. 1. If N equals 1, stop. 2. If N is even, divide it by 2, 3. Otherwise, triple it and add 1. 4. Go to step 0.
0. Write 0 on a piece of paper. 1. If M equals 0, report what's on the paper and stop. 2. Add N to the quantity written on the paper. 3. Subtract 1 from M. 4. Go to step 1.
Repeat 5 times, Shift each letter of the message to the right by 1
Repeat 3 times, Shift each letter of the message to the left by 7
Shift each letter of the message to the right by 3.
Shift each letter of the message to the left by 3.
Repeat until the message has real words, Shift each letter of the message to the left by 1
1. Select the smallest encoded word 2. let the shift amount be 0 3. Shift each letter of the message to the left by 1 4. increment the shift amount 5. if the smallest word is not a real word, goto 3 6. Shift the encoded phrase to the left by the shift amount 7. if the encoded phrase isn't only real words, goto 3
getName
.
double
.NurseryRhyme
class to “sing” either “Mary Had a Little Lamb” or your favorite nursery rhyme instead of Old MacDonald had a farm.Patterns
, modeled after OldMacDonald
, that will print the following patterns of asterisks, one after the other heading down the page:***** ***** ***** **** * * * * * *** * * * * ** * * * * * * ***** *****
****** * * * * ** ** * * * * * * ****** * * * * ** * * * * * * * * * * * * * * *
Temperature
object. It should store the current temperature in an instance variable of type double
, and it should have a public
constructor Temperature(double
t)
that initializes the instance variable, and one public
method, getTemp()
, which return
s the value of the instance variable. Use the Riddle
class as a model.TaxWhiz
that computes the sales tax for a purchase. It should store the current tax rate as an instance variable. Following the model of the Riddle
class, you can initialize the rate using a TaxWhiz()
constructor. This class should have one public
method, calcTax(double purchase)
, which will return
a double
, whose value is purchases
times the tax rate. For example, if the tax rate is 4 percent, 0.04, and the purchase is $100, then calcTax()
should return 4.0.num1
and num2
after the following statements are executed?int num1 = 5; int num2 = 8; num1 = num1 + num2; num2 = num1 + num2;
num1
:
num2
:
int
called num
and store in it the difference between 61 and 51.Riddle
class to contain a method named getRiddle()
that would return both the riddle’s question and answer.Circle
. It has one attribute, a radius
that is represented by a double
value. It has one operation, calculateArea()
, which returns a double
. Its attributes should be designated as private and its method as public.