Which of the following is NOT true about return statements? How many times will
ID: 3581189 • 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.
Which of the following is the method used to display a dialog box to gather input?
What layout manager should you use so that every component occupies the same size in the container?
The ActionListener interface contains the ____ method specification.
The method __________ sets the font (Helvetica, 20-point bold) in component C.
The methods in a subclass can use all of the data fields and methods that belong to its parent, with one exception: ____ members of the parent class are not accessible within a child class’s methods.
Which of the following statements starts a polygon named pol at the coordinates 20 and 290?
The ____ method requires four arguments and draws the outline of a rectangle using the current drawing color.
Usually, the subclass constructor only needs to initialize the ____ that are specific to the subclass.
Assume s is " abc ", the method __________ returns a new string "abc".
MysteryClass
According to the UML class diagram in the accompanying figure, which method is public and doesn’t return anything?
Flag this Question
To convert a String to an integer, you use the valueOf() method of the ____ class.
Which of the following most completely describes the steps for setting up event handling for a GUI component?
When an object of one class is a data field within another class, they are related by ____.
To specify an italic font, you pass ____ to the constructor.
Suppose s is a string with the value "java". What will be assigned to x if you execute the following code?
char x = s.charAt(4);
When you create a class and do not provide a(n) ____, Java automatically supplies you with a default one.
___________ can be used to enter or display a string.
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;
The JCheckBox, JComboBox, and JRadioButton components are associated with the ____ method.
The String class ____ method accepts an argument that identifies the field delimiter and returns an array of Strings.
Inheritance is an example of what type of relationship?
Exceptions can be thrown by:
____ variables are variables that are shared by every instantiation of a class.
Image objects are displayed using which Graphics method?
A value-returning method returns its value via the return statement.Explanation / Answer
1) Which of the following is NOT true about return statements?
Answer:
return statements can be used in void methods to return values. Void method doesn't return any value. So this option is not true related return statement.
2)
How many times will the following code print "Welcome to Java"
int count=0;
do {
System.out.println("Welcome to Java");
} while (count++ <10)
Answer: 10 times it will be executed.
3) Assuming a variable w has been assigned the value 15, what does the following statement do? w==15 ? x=2: x=0;
Answer:
W=15,
Condition is W equal to 15. So, it's true then first statement will be execute. Then answer is assign 2 to x.
Option is x=2.
4)
Every Java application is composed of at least one:
5) In order to allocate memory for an object, you use the ____ operator.
Answer:
6) The following loop displays _______________.
for (int i = 1; i <= 10; i++) {
System.out.print(i + " ");
i++;
}
Answer: 1,3,5,7,9
7) 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?
Answer:
8)
can be used to enter or display a string.
Answer:
A text field.
9)
Image objects are displayed using which Graphics method?
Answer is draimage() method used to display an image in applets.
10)
Inheritance is an example of what type of relationship?
Answer is : is-a relationship
is-a
12)
The String class ____ method accepts an argument that identifies the field delimiter and returns an array of Strings.
Answer is split() method is used to returns an array of strings.
split()
13)
The ActionListener interface contains the ____ method specification.
14)
The JCheckBox, JComboBox, and JRadioButton components are associated with the ____ method.
Answer is addItemListener () method
15) Which class do you use to read data from a text file?
Answer is scanner () method . Used to read text from files.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.