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

When a method returns an array reference, you include ____ with the return type

ID: 3581190 • Letter: W

Question

                                                                                                                                   

When a method returns an array reference, you include ____ with the return type in the method header.

a.            { }

b.            ( )

c.            < >

d.            [ ]

                                                                                                                                      

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

                                                                                                                                     

Each of the following is a relational or equality operator except:

a.            <=

b.            =!

c.            ==

d.            >

                                                                                                                                                       

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)

                                                                                                                                                     

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

                                                                                                                                                      

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


                                                                                                                                                        

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.


                                                                                                                                                        

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

                                                                                                                                                      

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

                                                                                                                                                      

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 value­returning method of type char.

                                                                                                                                                     

A(n) ____ method is a method that creates and initializes class objects.

a)           constructor

b)           accessor

c)           non­static

d)           instance

                                                                                                                                                     

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]

                                                                                                                                                  

The ____ requires three expressions separated with a question mark and a colon.

a)           flowchart

b)           conditional operator

c)           sequence structure

d)           conditional statement

                                                                                                                                                    

Which of the following is NOT true about return statements?

a)           A value­returning 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.

                                                                                                                                                     

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

a)           inheritance

b)           polymorphism

c)           encapsulation

d)           abstraction

                                                                                                                                                       

Which method contains the code that the program executes when a specific event is generated?

a)     buttonListener

b)     GUIListener

c)     actionPerformed

d)     windowListener

                                                                                                                                                      

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

                                                                                                                                                     

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

a)     addAdjustmentListener()

b)     addChangeListener()

c)     addWindowListener()

d)     addItemListener()

                                                                                                                                                      

Inheritance is an example of what type of relationship?

a)           is­a

b)           has­a

c)           was­a

d)           had­a

Explanation / Answer

1. (b) ( )

( ) paranthesis would return according to the reference of array

2. (a) assigns 2 to x

3. (b) =!

Actually the sign is reverse,I mean it should be like ' != '.

4. (c) showResult(12.2, 67)

5. (a) switch

6. (c) zero negative

7. (d) primitive

8. (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

9. (a) radius and (d) findarea

10. (d) a local variable

11. (d) It is a value­returning method of type char

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. (c) A method can have more than one return statement.

16. (b) polymorphism

17. (c) actionPerformed

18. (c) try

19. (d) addItemListener( )

20. (a) is­a

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