Answer all of the following questions. READ EACH QUESTION CAREFULLY. Each correct answer is worth 1 point. Each question has EXACTLY one correct answer.
Q1. Mae's accounting service helps each customer figure their tax owed.The customer's first name, middle initial and last name go on the form. The number of dependents is needed, along with the total income for the year. Mae charges a fee of 1.5% of total income for the service. Which one of the following would be the best suitable type for a variable that stores the number of dependents of the customer?
A. double
B. int
C. char
D. String
E. None of the above


Q2. Still referring to question 1, which one of the following would be a suitable type for a variable, that stores the last name of the customer?
A. double
B. int
C. char
D. String
E. None of the above

Q3.Still referring to the situation described in question 1, suppose the program which Mae uses has a method which, given the total income and the number of dependents (and no other information) computes and returns the tax owed. Such a method (choose the best answer)
A. would have more than two parameters and a void return type.
B. would have two parameters and a double return type.
C. would have less than two parameters and an int return type.
D. would have a void return type.
E. None of the above

Q4.Still referring to the problem described in question 1, what would be the best way to represent the 1.5% fee as a constant in the program?
A. public double fee=0.015
B. private double fee=0.015
C. public final String FEE="0.015"
D. public final double FEE=0.015
E. public final long FEE=0.015

Q5. Which of the following is TRUE about the switch statement in Java?
A. A default sends execution immediately to the end of the switch statement.
B. A break sends execution immediately to the end of the switch statement.
C. A case sends execution immediately to the end of the switch statement.
D. A break sends execution immediately to the end of the next case.
E. The statements in a switch continue to execute as long as the

Q6. Among these expressions, which is(are) of type String?
A. "0"
B. "ab"+"cd"
C. '0'
D. A and B
E. A, B and C

Q7.The interface of a class refers to
A. the list of all of the fields and methods of the class
B. the list of all of the public fields and public methods of the class
C. the list of all the private fields and public methods of the class
D. the list of all the private fields and private methods of the class
E. the comments written in the code of the class.

Q8. Consider the following code fragment
Rectangle r1 = new Rectangle();
r1.setColor(Color.blue);
Rectangle r2 = r1;
r2.setColor(Color.red);
After the above piece of code is executed, what are the colors of r1 and r2 (in this order)?
A. Color.blue Color.red
B. Color.blue Color.blue
C. Color.red Color.red
D. Color.red Color.blue
E. Can't tell. There is not enough information.

Q9. What is the type and value of the following expression? (notice the integer division) -- -4 + 1/2 + 2*-3 + 5.0
A. int -5
B. double -4.5
C. int -4
D. double -5.0
E. None of the above

Q10 . What is printed by the following statement?
System.out.print("Hello,nworld!");
A. Hello, n world!
B. Hello, world!
C. Hello, world!
D. "Hello, n world!"
E. None of the above.

Q11. In the class Car, you want to create an instance method is Speeding to check whether an object to type Car is speeding or not. One of the instance fields of the Car class is a double variable speed equal to the current speed of the Car object. The class also lists a constant static double field SPEED_LIMIT, equal to the legal speed limit for the driving conditions of the Car object. What method signature would be best for is Speeding?
A. public void is Speeding(double speed)
B. public boolean is Speeding()
C. public boolean is Speeding(double speed, double SPEED_LIMIT)
D. public is Speeding()
E. public boolean is Speeding(speed, SPEED_LIMIT)

Q12. Consider the two methods (within the same class)
public int foo(int a, String s)
{
s = "Yellow";
a=a+2;
return a;
}
public void bar()
{
int a=3;
String s = "Blue";
a = foo(a,s);
System.out.println("a="+a+" s="+s);
}
What is printed?
A. a=3 s=Blue
B. a=5 s=Yellow
C. a=3 s=Yellow
D. a=5 s=Blue
E. The code doesn't compile.

Q13. In Java, it is forbidden to use the same name for a local variable in two different methods. Using the Java class uwcse.graphics.Oval, which statement would you write to create a circle of radius 20, centered at x=100 and y=100.
A. new Oval(80,80,40,40);
B. new Oval(80,80,20,20);
C. new Oval(60,60,40,40);
D. new Oval(120,120,20,20);
E. new Oval(100,100,20,20);

Q14. Which of the following variable declaration would NOT compile in a Java program?
A. int var;
B. int VAR;
C. int var1;
D. int var_1;
E. int 1_var;

Q15. Using De Morgan’s law, how would you rewrite the following conditional statement (i.e. is rewrite the statement using && instead of ||)( c!='n' && +2<=5)
A. !(c!='n' || z+2<=5)
B. !(c=='n' || z+2>=5)
C. !(c!='n' || z+2<=5)
D. !(c=='n' || z+2>5)
E. !(c=='n' || z+2<5)

Important  Instructions

While submitting answers below in the " Message " Section MAKE SURE you type Question Number and Answer (For Example : 1. A , 2. B , 3.C ) and also mention the part number(For example: part 1, or part 2, or part 3 ) of the questions you are answering.

We will mail you your result in 10 seconds.Mention Course Name as Subject

Your Name (required)

Your Email (required)

Your Number (required)

Subject

Your Message