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

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

ID: 3580882 • Letter: J

Question

Java

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

Flag this Question

Question 21 pts

A method is declared as public static void showResults(double d, int i). Which of the following is a correct method call?

Flag this Question

Question 31 pts

A(n) ____ loop allows you to cycle through an array without specifying the starting and ending points for the loop control variable.

Flag this Question

Question 41 pts

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

Flag this Question

Question 51 pts

The ____ loop checks the value of the loop control variable at the bottom of the loop after one repetition has occurred.

Flag this Question

Question 61 pts

int[] numList = new int[50];

for (int i = 0; i <50;i++)

numList[i] = 2 * i;

num[10] = -20;
num[30] = 8;

What is the index number of the last component in the array numListseen in the accompanying figure?

Flag this Question

Question 71 pts

What is the output of the following Java code?

int x = 0;
if (x > 0)
    System.out.println("positive ");
    System.out.println("zero ");
System.out.println("negative");

Flag this Question

Question 81 pts

Where is the continue statement NOT usually used?

Flag this Question

Question 91 pts

What type of methods allow a client of a class to assign values to a private instance variable?

Flag this Question

Question 101 pts

A variable defined inside a method is referred to as __________.

Flag this Question

Question 111 pts

Which of the following is NOT a valid method to increase a variable named score by 1?

Flag this Question

Question 121 pts

Which of the following declares an array of int named beta?

Flag this Question

Question 131 pts

public int mystery(int x, int y)
{
    if (x >= y)
        return x - y;
    else
        return x + y;
}

Based on the code in the accompanying figure, what would be the output of the following statement?

System.out.println(mystery(8,7));

Flag this Question

Question 141 pts

public static char methodHeading(int n, double num)

Which of the following statements about the method heading in the accompanying figure is NOT true?

Flag this Question

Question 151 pts

The name of the ____ is always the same as the name of the class whose objects it creates.

Flag this Question

Question 161 pts

Which of the following statements is NOT true about GUI programs?

Flag this Question

Question 171 pts

You define the text to be displayed in a tool tip by using the setToolTipText() method and passing an appropriate ____ to it.

Flag this Question

Question 181 pts

Suppose the String variable str points to the String object "Sunny day" at the memory address 3600. Then the value of str is:

Flag this Question

Question 191 pts

The keyword ____ indicates that a field value is unalterable.

Flag this Question

Question 201 pts

The ____ method takes a String argument and returns its doublevalue.

Flag this Question

Question 211 pts

____ variables are variables that are shared by every instantiation of a class.

Flag this Question

Question 221 pts

Suppose str is a String variable. The statement

str = new String("Programming");

is similar to which of the following?

Flag this Question

Question 231 pts

When an object of one class is a data field within another class, they are related by ____.

Flag this Question

Question 241 pts

To specify an italic font, you pass ____ to the constructor.

Flag this Question

Question 251 pts

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

Flag this Question

Question 261 pts

Which of the following words indicates an object’s reference to itself?

Flag this Question

Question 271 pts

To create a window, which of the following classes has to be extended?

Flag this Question

Question 281 pts

The JCheckBox, JComboBox, and JRadioButton components are associated with the ____ method.

Flag this Question

Question 291 pts

Which class do you use to write data to a text file?

Flag this Question

Question 301 pts

The ActionListener interface contains the ____ method specification.

Flag this Question

Question 311 pts

The method header of the equals() method within the String class is ____.

Flag this Question

Question 321 pts

Given a Graphics object g, to draw an circle with radius 20 centered at (50, 50), you use __________.

Flag this Question

Question 331 pts

Calling a method has the ability to take many forms is called ________.

Flag this Question

Question 341 pts

Which JFrame JFrame method is used to display the frame?

Flag this Question

Question 351 pts

Which method can be used to create an input object for file temp.txt?

new Scanner(Paths.get("temp.txt"))

new Scanner(Path("temp.txt"))

Flag this Question

Question 361 pts

Inheritance is an example of what type of relationship?

Flag this Question

Question 371 pts

When you instantiate an object from a class, ____ is reserved for each instance field in the class.

Flag this Question

Question 381 pts

The ____ method creates a solid arc.

Flag this Question

Question 391 pts

Suppose that the class Mystery is derived from the class Secret. Consider the following statements.

Secret secRef = new Secret();
Mystery mysRef = new Mystery();

Which of the following statements is legal in Java?

(i)  secRef = mysRef;
(ii)  mysRef = secRef;

Flag this Question

Question 401 pts

Which of the following statements is true?

Flag this Question

Question 411 pts

Which of the following is used to allocate memory for the instance variables of an object of a class?

Flag this Question

Question 421 pts

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

Flag this Question

Question 431 pts

___________ can be used to enter or display a string.

Flag this Question

Question 441 pts

Which of the following is not a method of the class JTextField?

Flag this Question

Question 451 pts

Assume s is "    abc ", the method __________ returns a new string "abc".

Flag this Question

Question 461 pts

Which of the following statements starts a polygon named pol at the coordinates 20 and 290?

Flag this Question

Question 471 pts

The method __________ sets the font (Helvetica, 20-point bold) in component C.

Flag this Question

Question 481 pts

If a method throws an exception that it will not catch but that will be caught by a different method, you must also use the keyword ____followed by an Exception type in the method header.

Flag this Question

Question 491 pts

Which of the following statements depicts the valid format to call a superclass constructor from a subclass constructor?

Flag this Question

Question 501 pts

The ____ method requires four arguments and draws the outline of a rectangle using the current drawing color.

is undeclared

Explanation / Answer

1.1.goes out of scope

21.showResult(12.2, 67);

31.enhanced while

41.You can only define one constructor.

51.do while

61.30

71.positive zero negative

81.switch structures

91.set methods

101.a local variable

111.++score = score + 1

121.int beta = int[];

131.1

141.The method cannot be used outside the class.

151.constructor

161.All components are added directly to the GUI window.

171.string

181."Sunny day"

191.final

201.parseDouble()

211.Class/Static

221.str = "Programming";

231.composition/has-a

241.Font.ITALIC

251.only(1)

261.this

271.JFrame

281.addItemListener()

291.Scanner

301.actionEvent(ActionEvent e)

311.public boolean equals(String s)

321.g.drawOval(30, 30, 40, 40)

331.inheritance

341.display()

351.new Scanner(temp.txt)

361.has a

371.memory

381.solidArc()

391.Only (ii)

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

411.The reserved word static

421.polymorphism

431.A label

441.setEditable

451.s.trim()

461.pol.moveTo(20F, 290F);

471.c.setFont(new Font("Helvetica", Font.BOLD, 20))

481.throw

491.super(name, score);

501.fillRect()

Constructors do not have a return type.
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