Solved

Which of the Following Methods Calculates the Nth Fibonacci Number

Question 21

Multiple Choice

Which of the following methods calculates the nth Fibonacci number?


A) public static int method1(int n) {
if (n <= 2)
return 1;
else
return A(n - 1) ;
}
B) public static int method1(String str) {
if(str == null || str.equals("") )
return 0;
else
return 1 + method1(str.substring() ) ;
}
C) private static int method1(int Current, int Previous, int n) {
if (n == 1)
return Current;
else
return method1(Current + Previous, Current, n - 1) ;
}
D) public void method1(Object data) {
if (head == null)
head = new Node(data) ;
else
method1(head, data) ;
}

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents