1. Science
2. Other
3. andnbsp2 if object1 and object2 are objects of the same...

# Question: andnbsp2 if object1 and object2 are objects of the same...

###### Question details

REASON NOT REQUIRED MARK ONLY RIGHT ANSWER

2. If object1 and object2 are objects of the same class, to make object2 a copy of object1:

A) assign object1 to object2, such as object2 = object1;

B) write a copy method that will make a field by field copy of object1 data members into object2 data members

C) use the Java copy method that is a part of the Java language

D) use the default constructor to create object2 with object1 data members

3. What will be the value of x after the following code is executed?

int x = 75;

int y = 60;

if (x > y)

x = x - y;

A) 75

B) 15

C) 60

D) 135

4. What will be the value of ans after the following code has been executed?

int x = 90, y = 55, ans = 10;

if ( x == y);

ans *= 2;

A) 10

B) 145

C) 20

D) No value, there is a syntax error.

5. What will be the value of bonus after the following code is executed?

int bonus, sales = 10000;

if (sales < 5000)

bonus = 200;

else if (sales < 7500)

bonus = 500;

else if (sales < 10000)

bonus = 750;

else if (sales < 20000)

bonus = 1000;

else

bonus = 1250;

A) 200

B) 500

C) 750

D) 1000

E) 1250

6. What would be the value of discountRate after the following statements are executed?

double discountRate = 0.0;

int purchase = 1250;

char cust = 'N';

if (purchase > 1000)

if (cust == 'Y')

discountRate = .05;

else

discountRate = .04;

else if (purchase > 750)

if (cust == 'Y')

discountRate = .04;

else

discountRate = .03;

else

discountRate = 0;

A) .05

B) .04

C) .03

D) 0

7. In the following code, Integer.parseInt(str), is an example of:

int num;

string str = "555";

num = Integer.parseInt(str) + 5;

A) a value-returning method

B) a void method

C) a local variable

D) a complex method

###### Solution by an expert tutor 