Question: class Tester { public void myMethod( int one, double two ) { one = 25; two = 35.4; } } Question: What will be the
class Tester
{
public void myMethod( int one, double two )
{
one = 25;
two = 35.4;
}
}
Question: What will be the output from the following code?
Tester tester;
int x, y;
tester = new Tester() ;
x = 15;
y = 25;
tester.myMethod( x, y ) ;
System.out.println( x + " , " + y ) ;
| 25 , 15 |
| 25 , 35.4 |
| 15 , 25 |
| 35.4 , 25
Consider the following classes below. Identify the invalid statements in the following mainclass. (You must select all lines of code from the main method that are invalid.)
class Cat { private String name; private Breed breed; private double weight;
public Cat(String name, Breed breed, double weight){ this.name = name; this.breed = breed; this.weight = weight; }
public Breed getBreed() { return breed; }
public double getWeight() { return weight; }
//other accessors and mutators . . . }
class Breed { private String name; private double averageWgt; //in lbs.
public Breed(String name, double averageWgt){ this.name = name; this.averageWgt = averageWgt; }
public double getWeight( ) { return averageWgt; }
//other accessors and mutators . . . } class Q1Main { public static void main( String[] args ) { Breed persian = new Breed("Persian", 10.0); Cat chacha = new Cat("Cha Cha", persian, 12.0); Cat bombom = new Cat("Bom Bom", "mix", 10.0); 1 Cat puffpuff = new Cat("Puff Puff", chacha, 9.0); 2 double diff = chacha.getWeight() - persian.getWeight(); System.out.println( puffpuff.getBreed().getWeight()); } }
| |||||||||||||||
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts

