Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which of the following is NOT true about return statements? How many times will

ID: 3581183 • Letter: W

Question

Which of the following is NOT true about return statements?

How many times will the following code print "Welcome to Java"
int count=0;
do {
System.out.println("Welcome to Java");
} while (count++ <10)

Assuming a variable w has been assigned the value 15, what does the following statement do? w==15 ? x=2: x=0;

In which of the following statements is the value of myVals null?

Every Java application is composed of at least one:

In order to allocate memory for an object, you use the ____ operator.

The following loop displays _______________.

for (int i = 1; i <= 10; i++) {
System.out.print(i + " ");
i++;
}

int larger(int x, int y)

Given the method heading in the accompanying figure, which of the following would be an incorrect demonstration of method overloading?

Which of the following statements are true about constructors of a class? (Choose all that apply)

Suppose method1 is declared as

void method1 ( int a, float b )

Which of the following methods correctly overloads method1?

When a variable ceases to exist at the end of a method, programmers say the variable ____.

How many times will outputLabel be called?
for(customer = 1; customer <= 20; ++customer)
     for(color = 1; color <= 3; ++color)
          outputLabel();

Consider the following method definition.

public static int strange(int[] list, int listSize, int item)
{
   int count = 0;

   for (int j = 0; j <listSize;j++)

if (list[j] == item)
          count++;

   return count;
}

Which of the following statements best describe the behavior of this method?

What is value of x after the following code executes?

int x = 0;
int i;

for (i = 0; i <5; i++)

x = 3 * x + i;

Which of the following should be defined as a void method?

Suppose str is a String variable. The statement

str = new String("Programming");

is similar to which of the following?

Any of the file input or output methods in a Java program might throw an exception, so all the relevant code in the class is placed in a ____ block.

Which of the following statements is true?

The ____ method creates a solid arc.

If graph holds a Graphics object, which of the following puts "CAT" starting at X = 20, Y = 50?

Which of the following exceptions might be thrown by the methods of the class String?

Which class do you use to read data from a text file?

Which of the following creates a color object? (Choose all that apply)

Which of the following is a valid statement?
(i) int num = new int(67);
(ii) String name = new ("Doe");
(iii) String name = "Doe";

When you employ ____, your data can be altered only by the methods you choose and only in ways that you can control.

A value-returning method returns its value via the return statement.

Explanation / Answer

-> A method can have more than one return statement.

-> 11

-> assigns 2 to x

-> myVals = int[null]

-> public class declaration

-> new

-> 1 2 3 4 5 6 7 8 9 10

-> int larger(int a, int b)

-> Constructors must have the same name as the class itself.

-> void method1 ( float a, int b ).

-> goes out of scope

-> 60

-> This method returns the number of times item is stored in list.

-> 226

-> Write a method that prints integers from 1 to 100.

-> str = "Programming";

-> catch

-> The class Throwable, which is derived from the class Exception, is the superclass of the class Object.

-> fillArc()

-> graph.drawString(20, 50, "CAT");

-> NullPointerException

-> Scanner

-> new Color(255, 255, 255)

-> Only (i) and (ii)

-> information hiding

Constructors are invoked using the new operator when an object is created.
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote