Question 1 When a method returns an array reference, you include ____ with the r
ID: 3581207 • Letter: Q
Question
Question 1
When a method returns an array reference, you include ____ with the return type in the method header.
a. { }
b. ( )
c. < >
d. [ ]
Question 2
Assuming a variable w has been assigned the value 15, what does the following statement do? w==15 ? x=2: x=0
a) assigns 2 to x
b) assigns 15 to w
c) assigns 0 to x
d) nothing
Question 3
Each of the following is a relational or equality operator except:
a. <=
b. =!
c. ==
d. >
Question 4
A method is declared as public static void showResults(double d, int i). Which of the following is a correct method call?
a) showResult(double d, int i)
b) showResult(4, 99.7)
c) showResult(12.2, 67)
d) showResult(12.2, 99.7)
Question 5
The ____ statement is useful when you need to test a single variable against a series of exact integer, character, or string values.
a) switch
b) if
c) else
d) break
Question 6
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")
a) zero
b) negative
c) zero negative
d) positive zero negative
Question 7
When any ____ type (boolean, char, byte, short, int, long, float, or double) is passed to a method, the value is passed.
a) array
b) dummy
c) element
d) primitive
Question 8
Which of the following statements are true about constructors of a class? (Choose all that apply)
a) You can only define one constructor.
b) Constructors do not have a return type.
c) Constructors must have the same name as the class itself.
d) Constructors are invoked using the new operator when an object is created.
Question 9
Which of the following are correct names for variables according to Java naming conventions? (Choose all that apply)
a) radius
b) Radius
c) RADIUS
d) findArea
Question 10
A variable defined inside a method is referred to as __________.
a) a global variable
b) a method variable
c) a block variable
d) a local variable
Question 11
public static char methodHeading(int n, double num)
Which of the following statements about the method heading in the accompanying figure is NOT true?
a) The method has two parameters.
b) The method cannot be used outside the class.
c) methodHeading is an identifier giving a name to this specific method.
d) It is a valuereturning method of type char.
Question 12
A(n) ____ method is a method that creates and initializes class objects.
a) constructor
b) accessor
c) nonstatic
d) instance
Question 13
Which of the following is incorrect? (Choose All that apply)
a) int[] a = new int[2]
b) int a() = new int[2]
c) int[] a = new int(2)
d) int a = new int[2]
Question 14
The ____ requires three expressions separated with a question mark and a colon.
a) flowchart
b) conditional operator
c) sequence structure
d) conditional statement
Question 15
Which of the following is NOT true about return statements?
a) A valuereturning method returns its value via the return statement.
b) return statements can be used in void methods to return values.
c) A method can have more than one return statement.
d) Whenever a return statement executes in a method, the remaining statements are skipped and the method exits.
Question 16
Calling a method has the ability to take many forms is called ________.
a) inheritance
b) polymorphism
c) encapsulation
d) abstraction
Question 17
Which method contains the code that the program executes when a specific event is generated?
a) buttonListener
b) GUIListener
c) actionPerformed
d) windowListener
Question 18
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.
a) finally
b) throw
c) try
d) catch
Question 19
The JCheckBox, JComboBox, and JRadioButton components are associated with the ____ method.
a) addAdjustmentListener()
b) addChangeListener()
c) addWindowListener()
d) addItemListener()
Question 20
Inheritance is an example of what type of relationship?
a) isa
b) hasa
c) wasa
d) hada
Explanation / Answer
Answers:
1)d. [ ]
2)a) assigns 2 to x
3) All are correct
4)c) showResult(12.2, 67)
5)a) switch
6)c) zero negative
7)c) element
8)a) You can only define one constructor.,c) Constructors must have the same name as the class itself.
d) Constructors are invoked using the new operator when an object is created.
9)a) radius ,d) findArea
10)d) a local variable
11)b) The method cannot be used outside the class.
12)d) instance
13)b) int a() = new int[2] ,c) int[] a = new int(2) ,d) int a = new int[2]
14)b) conditional operator
15)b) return statements can be used in void methods to return values.
16)b) polymorphism
17)c) actionPerformed
18)c) try
19)d) addItemListener()
20)a) isa
Note:Please ask in case of any doubt,Thanks!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.