Question

Question 10 (3 points) Which of the following statement is not true? There is a recursive sum method as shown below. When sum

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question 10:

First option is the correct answer.

The program will run an infinite loop as the only stopping condition provided in the code is:

if (x == 0)

But the value of x will never be zero as it will return all the odd numbers less than 19 and in each iteration the sum is decreased by two. So, when it will be 1 in the next iteration it will be -1. So, no stopping condition will be satisfied.

Second option is incorrect as it is true.

Third option is incorrect as it is true.

Fourth option is incorrect as it is true.

The given question has two questions included in it. As per the HOMEWORKLIB RULESs I have answered the first question and requesting you to re-post the remaining question as a separate one.
Please comment in case of any doubt.
Please upvote if this helps.

Add a comment
Know the answer?
Add Answer to:
Question 10 (3 points) Which of the following statement is not true? There is a recursive...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 11 (3 points) What does the following recursive method determine? public boolean question 16(int[]a, int[]...

    Question 11 (3 points) What does the following recursive method determine? public boolean question 16(int[]a, int[] b. intj) { if (j == 2.length) return false; else if ( == b.length) return true; else return question 16(2, b.j+1): 3 returns true if b contains less elements than a, false otherwise returns true if b contains more elements than a, false otherwise returns true if a and bare equal in size, false otherwise returns true if a's element value is larger than...

  • True False Question 2 (3 points) Given a singly linked list with more than two nodes,...

    True False Question 2 (3 points) Given a singly linked list with more than two nodes, to remove the second node from a linked list with only head reference, assume curr - head, next, you do Set curr.next to head.next Oset head. next to curr.next Set head, next to curr Oset head to curr.next TL th Question 3 (3 points) Given the following singly linked list (a list with four nodes), what will be the value stored at the last...

  • Question 5 (10 points) Assume you have the following code, with blanks to be filled in...

    Question 5 (10 points) Assume you have the following code, with blanks to be filled in below. public static void g () ( throw new () public static void f() try ) catch ( 12), e) System.out.print ("A") ; return } catch ( System.out. print ("B") throw ei e) ( 13) catch ( 14) e) ( System.out.print ("C") ; } finally System.out.print ("D") ; System.out.print ("E") ; } public static void main (String (] args) try f() } catch (...

  • Question 5 (3 points) (Bonus) Below shows a recursive method that can recognize whether a String...

    Question 5 (3 points) (Bonus) Below shows a recursive method that can recognize whether a String parameter consists of a specific pattern and returns true if the String has that pattern, false otherwise. public boolean pattern Recognizer(String 2) return true; if (2 == null) return true; else if (a.length(== 11 |(a.length() == 2&&2.charAt(0) == 2.charAt()))) else if (a.length() == 2 && 2.charAt(0) != a.charAt(1)) return false; else if (a.charAt(0) == a.charAt(a.length() - 1)) retum patterRecognizer(a substring(1, a.length() - 1)): else...

  • Please provide the full code...the skeleton is down below: Note: Each file must contain an int...

    Please provide the full code...the skeleton is down below: Note: Each file must contain an int at the beginning, stating the number of records in the file. Afterwards, the number of records in the file will follow. Each record that follows will consist of a last name (String), and a gpa (double). However, to test the error handling of your program, the number of records will not always match the int value. All possible combinations should be tested. 1.) Prompt...

  • Question 1 (5 points) Question 1 Unsaved What is displayed on the console when running the...

    Question 1 (5 points) Question 1 Unsaved What is displayed on the console when running the following program? public class Quiz2B { public static void main(String[] args) { try { System.out.println("Welcome to Java"); int i = 0; int y = 2 / i; System.out.println("Welcome to Java"); } catch (RuntimeException ex) { System.out.println("Welcome to Java"); } finally { System.out.println("End of the block"); } } } Question 1 options: The program displays Welcome to Java two times. The program displays Welcome to...

  • Question 20 Statements that might generate an exception are placed in a catch block. True False...

    Question 20 Statements that might generate an exception are placed in a catch block. True False 1 points Question 21 The class Exception and its subclasses are designed to catch exceptions that should be caught and processed during program execution. True False 1 points Question 22 Which of the following statements is NOT true about creating your own exceptions? Typically, constructors are the only methods that you include when you define your own exception class. The exception class that you...

  • software testing without making any changes to the java classes provided below, come up with some...

    software testing without making any changes to the java classes provided below, come up with some junit test cases to test the code. To get you started, here are four test cases you must implement: • Use the setString() function in MyCustomStringInterface to set the value to “H3y, l3t'5 put s0me d161ts in this 5tr1n6!11!!”. Then test to see if the CountNumbers() function is equal to the number of sequential digits in the original string (in this case, 9). •...

  • QUESTION 21 What exception will the following program raise? class Main f public static void main(Stringl...

    QUESTION 21 What exception will the following program raise? class Main f public static void main(Stringl args) try System.out.print Hello"1/0); catch ( e) f codes are not provided** DataFormatException InputMismatchException ArithmeticException DividedByZeroException QUESTION 19 Suppose we had the following method header: public void someMethod (int someNumber) Which of the following is an overloaded version of this method? public void someMethod (int someNumber, int anotherNumber) O public int someMethod (int anotherNumber) O public void someMethod (int anotherNumber) public void anotherMethod (int...

  • absolute C++ QUESTION 1 Which statement is incorrect? When an event occurs that cannot be managed...

    absolute C++ QUESTION 1 Which statement is incorrect? When an event occurs that cannot be managed locally, an exception may be thrown. Throwing the exception object transfers control and information gleaned locally to some calling program unit that manages the event, or the program terminates If an exception is thrown in a function, sayf, but not handled there, the exception is propagated to the function that called fo In C++, an exception object can be a user-defined type or any...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT