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

PLEASE Help answer Java test review questions! 1) Which of the following stateme

ID: 3840593 • Letter: P

Question


PLEASE Help answer Java test review questions!

1) Which of the following statements about recursion are TRUE? Select all that apply.

a)Infinite recursion could happen if there were an infinite amount of memory available

b)Recursive solutions are always simpler than iterative solutions

c)Every solution that can be solved by using loops can also be solved recursively

d)Recursion involves the repeated execution of a segment of code.

e)Recursion only happens when a function calls itself

f) There are no drawbacks to using recursion.

2)

Which of the things below are TRUE of the abstract keyword. Select all that apply.

a)prevents a class from being extended

b)prevents a subclass from overriding the abstract method

c)prevents a class from defining constructors

d)prevents a method from being defined in the class

e)prevents the class from being used as a data type

f)prevents a class from being instantiated

3)

Given the code below, which of the following statements will properly read a character from the keyboard.


Scanner OldMan = new Scanner(System.in);

System.out.println("It is dangerous to go alone. Take this? (Y/N): "

a)String yesno = OldMan.next();

char answer = (char)yesno;



b)String yesno = OldMan.next();

char answer = yesno.charAt(0);


c)char answer = OldMan.nextChar();

d)char answer = OldMan.getNext();

4)

Match the following terms with the correct definition.

Question

Selected Match

Java Language Specification

D.

defines the syntax of Java

API

F.

used to develop server-side applications

JDK

A.

contains predefined classes and interfaces

IDE

B.

a graphical user interface for editing, compiling, and debugging Java programs

A.

contains predefined classes and interfaces

B.

a graphical user interface for editing, compiling, and debugging Java programs

C.

set of separate programs used to develop and test Java programs

D.

defines the syntax of Java

E.

used to develop applications for mobile devices

F. used to develop server-side applications

5)

Which of the following function headers is syntactically correct?

a)public static void HeyListen (int... fairies, String... Navi)



b)public static int... HeyListen (int fairies, String Navi)



c)public static void HeyListen (int... fairies, String Navi)


d)public static void HeyListen (String Navi, int... fairies)

6)

Examine the following source code. Assume this is a complete file named Epona.java. Which of the items below would be treated as a syntax error when compiling the code? Select all that apply.


import java.util.*;

package Hyrule;


public class Epona

{

void setGallopSpeed(int x)

{   gallopSpeed = x;   }

static private int gallopSpeed;

private double weight;

public void speedUp()

{   this.speedUp(10);   }

public void speedUp(int x)

{  this.setGallopSpeed(x);   }

}

a)lack of access specifiers for function

b)package statement

c)importing an unused library

d)use of static for variables

e)placement of class variables

f)use of this to call overloaded function

g)use of this to call a non-overloaded function

7)

Which of the following things are accomplished by the final keyword?

a)prevents a variable from being modified

b)prevents a method from being overridden

c)prevents a method from being overloaded

e)prevents an interface from being implemented

f)initiates the last iteration of a loop

g)prevents a class from being extended

8)

Which of the following statements are TRUE of immutable objects? Select all that apply.

a)There cannot be any mutator methods for the class variables

b)The class variables must be of a primitive data type

c)All class variables must be private

d)All class methods must be static

e)Accessor methods cannot return a class variable reference to an object that can be modified

f)The class must be declared as abstract

9)

Which of the following statements are FALSE? Select all that apply.

a)When space for an array is allocated, each element is assigned a default value.

b)Declaring an array variable allocates space for the array in memory

c)An array can be created without explicitly stating the size of the array

d)When used with an array variable, the assignment operator (array1 = array2) creates a deep copy.

e)Non-constant values can be used to declare the size of an array.

f)Arrays can be returned from a function

10)

Which of the following code segments will produce a syntax error? Select all that apply.

a)int hearts = 3;

hearts += 2.5;


b)char letter = 'L';

System.out.println((char)((int)letter));


c)String rupees = '1' + "00";


d)char letter = 'Z';

e)if (letter >= 'A' && letter <= 'Z')

System.out.println(letter + "elda");


f)float potion = 3.5;

int hearts = (int) potion;


g)long sword = 10;

int arrow = sword;

11) Given the following code segment, what output would be generated?


int rupees = 500;

String [] inventory = new String[10];

try

{

inventory[10] = "Deku Mask";

rupees -= 100;

}

catch (Exception ex)

{ rupees += 100;   }

catch (IndexOutOfBoundsException ex2)

{   rupees -= 200; }

finally

{   rupees += 300; }

System.out.println(rupees);

a)600

b)800

c)900

d)700

12)

Which of the following statements about interfaces are FALSE? Select all that apply.

a)all methods are public

b)the interface can be instantiated by using the new keyword

c)only one interface can be implemented per class

d)all methods are static

e)access specifiers are optional when declaring the interface members

f)all variables in the interface are abstract

g)all methods are abstract


a)Infinite recursion could happen if there were an infinite amount of memory available

b)Recursive solutions are always simpler than iterative solutions

c)Every solution that can be solved by using loops can also be solved recursively

d)Recursion involves the repeated execution of a segment of code.

e)Recursion only happens when a function calls itself

f) There are no drawbacks to using recursion.

2)

Which of the things below are TRUE of the abstract keyword. Select all that apply.

a)prevents a class from being extended

b)prevents a subclass from overriding the abstract method

c)prevents a class from defining constructors

d)prevents a method from being defined in the class

e)prevents the class from being used as a data type

f)prevents a class from being instantiated

3)

Given the code below, which of the following statements will properly read a character from the keyboard.


Scanner OldMan = new Scanner(System.in);

System.out.println("It is dangerous to go alone. Take this? (Y/N): "

a)String yesno = OldMan.next();

char answer = (char)yesno;



b)String yesno = OldMan.next();

char answer = yesno.charAt(0);


c)char answer = OldMan.nextChar();

d)char answer = OldMan.getNext();

4)

Match the following terms with the correct definition.

Question

Selected Match

Java Language Specification

D.

defines the syntax of Java

API

F.

used to develop server-side applications

JDK

A.

contains predefined classes and interfaces

IDE

B.

a graphical user interface for editing, compiling, and debugging Java programs

A.

contains predefined classes and interfaces

B.

a graphical user interface for editing, compiling, and debugging Java programs

C.

set of separate programs used to develop and test Java programs

D.

defines the syntax of Java

E.

used to develop applications for mobile devices

F. used to develop server-side applications

5)

Which of the following function headers is syntactically correct?

a)public static void HeyListen (int... fairies, String... Navi)



b)public static int... HeyListen (int fairies, String Navi)



c)public static void HeyListen (int... fairies, String Navi)


d)public static void HeyListen (String Navi, int... fairies)

6)

Examine the following source code. Assume this is a complete file named Epona.java. Which of the items below would be treated as a syntax error when compiling the code? Select all that apply.


import java.util.*;

package Hyrule;


public class Epona

{

void setGallopSpeed(int x)

{   gallopSpeed = x;   }

static private int gallopSpeed;

private double weight;

public void speedUp()

{   this.speedUp(10);   }

public void speedUp(int x)

{  this.setGallopSpeed(x);   }

}

a)lack of access specifiers for function

b)package statement

c)importing an unused library

d)use of static for variables

e)placement of class variables

f)use of this to call overloaded function

g)use of this to call a non-overloaded function

7)

Which of the following things are accomplished by the final keyword?

a)prevents a variable from being modified

b)prevents a method from being overridden

c)prevents a method from being overloaded

e)prevents an interface from being implemented

f)initiates the last iteration of a loop

g)prevents a class from being extended

8)

Which of the following statements are TRUE of immutable objects? Select all that apply.

a)There cannot be any mutator methods for the class variables

b)The class variables must be of a primitive data type

c)All class variables must be private

d)All class methods must be static

e)Accessor methods cannot return a class variable reference to an object that can be modified

f)The class must be declared as abstract

9)

Which of the following statements are FALSE? Select all that apply.

a)When space for an array is allocated, each element is assigned a default value.

b)Declaring an array variable allocates space for the array in memory

c)An array can be created without explicitly stating the size of the array

d)When used with an array variable, the assignment operator (array1 = array2) creates a deep copy.

e)Non-constant values can be used to declare the size of an array.

f)Arrays can be returned from a function

10)

Which of the following code segments will produce a syntax error? Select all that apply.

a)int hearts = 3;

hearts += 2.5;


b)char letter = 'L';

System.out.println((char)((int)letter));


c)String rupees = '1' + "00";


d)char letter = 'Z';

e)if (letter >= 'A' && letter <= 'Z')

System.out.println(letter + "elda");


f)float potion = 3.5;

int hearts = (int) potion;


g)long sword = 10;

int arrow = sword;

11) Given the following code segment, what output would be generated?


int rupees = 500;

String [] inventory = new String[10];

try

{

inventory[10] = "Deku Mask";

rupees -= 100;

}

catch (Exception ex)

{ rupees += 100;   }

catch (IndexOutOfBoundsException ex2)

{   rupees -= 200; }

finally

{   rupees += 300; }

System.out.println(rupees);

a)600

b)800

c)900

d)700

12)

Which of the following statements about interfaces are FALSE? Select all that apply.

a)all methods are public

b)the interface can be instantiated by using the new keyword

c)only one interface can be implemented per class

d)all methods are static

e)access specifiers are optional when declaring the interface members

f)all variables in the interface are abstract

g)all methods are abstract


Explanation / Answer

3) Given the code below, which of the following statements will properly read a character from the keyboard? Scanner Old Man = new Scanner (System. in);

System. out.println ("It is dangerous to go alone. Take this? (Y/N): "

Option: c

Answer: char answer = OldMan.nextChar ();

4)

Java language specification -- used to develop server-side applications

      API                                     --   contains predefined classes and interfaces

    

      JDK                                    --   defines the syntax of Java

      IDE                                    -- set of separate programs used to develop and test Java programs

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