GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Consider the method powerOfTwo shown below: public boolean…

Consider the method powerOfTwo shown below: public boolean powerOfTwo(int n) { if (n == 1) // line #1 { return true; } else if (n % 2 == 1) // line #2 { return false; } else { return powerOfTwo(n / 2); // line #3 } } What is the best interpretation of line #1?

Read Details

If an element is present in an array of length n, how many e…

If an element is present in an array of length n, how many element visits, in the worst case, are necessary to find it using a linear search?

Read Details

Consider the method below, which displays the characters fro…

Consider the method below, which displays the characters from a String in reverse order.  Each character appears on a separate line.  Select the statement that should be used to complete the method so that it performs a recursive method call correctly. public static void printReverse(String word) { if (word.length() > 0) { ___________________________ System.out.println(word.charAt(0)); } }

Read Details

Which of the following objects should be used for reading fr…

Which of the following objects should be used for reading from a text file?

Read Details

Which of the following classes have a user-editable area?

Which of the following classes have a user-editable area?

Read Details

You need to access values by an integer position.  Which col…

You need to access values by an integer position.  Which collection type should you use?

Read Details

Complete the code shown to define the Comparator interface f…

Complete the code shown to define the Comparator interface for comparing Auto objects. public interface Comparator { _____________________ }

Read Details

A palindrome is a word or phrase that reads the same forward…

A palindrome is a word or phrase that reads the same forward or backward. Consider the following code snippet: public boolean palindrome(String string) { return isPal(string, 0, string.length() – 1); } private boolean isPal(String string, int left, int right) { if (left >= right) { return true; } else if (string.charAt(left) == string.charAt(right)) { return isPal(string, left + 1, right – 1); } else { return false; } } What is the purpose of the palindrome method?

Read Details

Consider the following code snippet: Vehicle aVehicle = new…

Consider the following code snippet: Vehicle aVehicle = new Auto(); aVehicle.moveForward(200); If the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type, which statement is correct?

Read Details

If the user wants to process keystrokes, which methods of th…

If the user wants to process keystrokes, which methods of the KeyListener interface must be implemented?

Read Details

Posts pagination

Newer posts 1 … 76,272 76,273 76,274 76,275 76,276 … 81,552 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top