Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following class. public class CrazyArithmetic { private String answer; public CrazyArithmetic(int a, int b, String operator) { if (operator.equals(/)) answer = ((double)a/b)+; else

Consider the following class.

public class CrazyArithmetic {

private String answer;

public CrazyArithmetic(int a, int b, String operator) {

if (operator.equals("/")) answer = ((double)a/b)+"";

else if (operator.equals("*&")) answer = (a*b)+"";

else if (operator.equals("-")) answer = (a-b)+"";

else if (operator.equals("+")) answer = (double)(a+b)+"";

}

public CrazyArithmetic(double a, double b, String operator) {

if (operator.equals("/")) answer = ((int)a/(int)b)+"";

else if (operator.equals("*")) answer = (a*b)+"";

else if (operator.equals("-")) answer = (a-b)+"";

else if (operator.equals("+")) answer = (int)(a+b)+"";

}

public CrazyArithmetic(double a, int b, String operator) {

answer = new CrazyArithmetic(a,(double)b,operator).getAnswer();

}

public CrazyArithmetic(int a, double b, String operator) {

answer = new CrazyArithmetic(a,(int)b,operator).getAnswer();

}

public String getAnswer() {

return answer;

}

}

Which of the following statements would execute without throwing an error?

I. CrazyArithmetic c1 = new CrazyArithmetic(5.0, 10.0, "add");

II. CrazyArithmetic c2 = new CrazyArithmetic(20.0, 8, "/");

III. CrazyArithmetic c3 = new CrazyArithmetic(2, 4, "/");

Select one answer

A III only.

B I and II only.

C II and III only.

D I and III only.

E I, II, and III.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

Solve time value of money problems using uneven cash flows.

Answered: 1 week ago

Question

What is the relationship between humans and nature?

Answered: 1 week ago