Question
JAVA Test 2 of 2: Modul 04 Which of the following sentences are correct for setting the length of a keyframe to one second (the
JAVA Test 2 of 2: Modul 04
Which of the following sentences are correct for setting the length of a keyframe to one second (the time between each call to the event listener acting):
- several alternatives possible
1. new KeyFrame(1000, handler)
2. new KeyFrame(1, handler)
3. KeyFrame(Duration.millis(1000), handler)
4. KeyFrame(Duration.seconds(1), handler)
Given the following code, what will print to screen if user presses down arrow?
public class KeyPressedTest extends Application { @Override public void start(Stage primaryStage) { // Code to create and display pane omitted Pane pane = new Pane(); Scene scene = new Scene(pane, 200, 250); primaryStage.setTitle("MyJavaFX"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage pane.requestFocus(); pane.setOnKeyPressed(e -> System.out.print("Key pressed " + e.getCode() + " ")); pane.setOnKeyTyped(e -> System.out.println("Key typed " + e.getCharacter())); }
1. Key pressed DOWN Key typed UNDEFINED
2. Key pressed DOWN Key typed
3. Key typed UNDEFINED
4. Key pressed DOWN
Given code as in the previous question, what will print if user press h (small h)?
1. Key pressed H Key typed h
2. Key pressed h Key typed
3. Key pressed 68 Key typed h
4. Key pressed H Key typed 65
Which classes are a subclass of Animation? - several alternatives possible
1. Timeline
2. PathTransition
3. FadeTransition
4. Duration
Pre: Modul 05
Which of the following data structures is used by the operating system to keep track of recursion?
1. Queue
2. AVL tree
3. array
4. stack
5. Binary tree
What is the basic case in the following recursive method?
1. n> 0
2. n> = 0
3. The method does not have basic cases
4. n <0
5. n <= 0
Which of the following statements is not true about recursion and iteration?
1. A recursive algorithm must have a basic case to terminate
2. Generally speaking, recursive algorithms provide better performance than iterative
3. A recursive method is a method that calls itself
4. Any recursive method can be rewritten to iterative form (with loop)
5. Recursive calls take time and use extra space in memory
Analyze the following method and select the correct answer.
public static long faculty(int n) { return n * faculty(n - 1); }
1. calling with faculty (0) returns 0.
2. calling with faculty (2) returns 2.
3. calling with faculty (3) returns 6.
4. calling with faculty (1) returns 1.
5. The method runs endlessly and leads to StackOverflowError.
How many times does the factorial method start in program list 18.1 for factorial (5)
1. 3
2. 5
3. 4
4. 6
Which of the following statements about recursion are true? - several alternatives possible
1. Each recursive call must reduce the original problem so that it gets closer to the base case, until finally it reaches it.
2. Infinite recursion can occur if the recursive calls do not reduce the original problem so that one finally reaches the base case
3. The call to a recursive method takes place in a different way than non-recursive method calls
4. All recursive methods must have a return value. They cannot be void.
5. Each recursive method must have a basic case or stop condition
Which of the options below can be inserted for ________, after the return in the method below, in order for it to be a complete recursive method for calculating the faculty?
- several alternatives possible
// Return the faculty for the specified index * /
public static long faculty (int n) {
if (n == 0) // Basic case
return 1;
else return _______;
// Recursive call }
1. faculty (n - 1) 2. n * (n - 1) 3. faculty (n - 1) * n 4. n * faculty (n - 1) 5. n
Which of the following statements is true regarding the Fibonacci array
1. It starts with 0 and 1, the next number in the row is the sum of two previous numbers I
2. t starts with 2 and 3, the next number in the row is the sum of two previous numbers
3. It starts with 1 and 1, the next number in the row is the sum of two previous numbers
I4. t starts with 1 and 2, the next number in the row is the sum of two previous numbers
Which alternatives can be used as the return value for this method to be able to calculate Fibonacci numbers on the given index? - several alternatives possible
public static long fib(long index) { if (index == 0) return 0; else if (index == 1) return 1; else return __________________; }
1. fib(index - 2) + fib(index - 1)
2. fib(index - 1)
3. fib(index - 1) + fib(index - 2)
4. fib(index - 2)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started