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

to me

class Tester { public void myMethod( int one, double two ) {

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());

}

}

Cat puffpuff = new Cat("Puff Puff", chacha, 9.0);
Cat bombom = new Cat("Bom Bom", "mix", 10.0);
double diff = chacha.getWeight() - persian.getWeight();
Cat chacha = new Cat("Cha Cha", persian, 12.0);
Breed persian = new Breed("Persian", 10.0);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!