Question: JAVA From 22 to end pleases Thank you ? 22. Abstract classes a. An abstract class can contain b. Can you create an object from
JAVA
From 22 to end pleases Thank you
?
22. Abstract classes a. An abstract class can contain b. Can you create an object from an Abstract class C. Can it have constructors? d. Can it have methods which are not abstract? e. Can it have instance variables methods 23. Write an abstract class Animal. The Animal class has a name and birth year. It has getters and setters for the instance variables and a no-arg constructor. It also has an abstract method, speak, which returns a String 24. Write a class Cat which is a subclass of Animal. The Cat class has an additional instance variable, hair-length. Write getters and setters for the Cat class. Write a constructor for the Cat class which takes name, birth year and hair length as parameters and values the instance variables of Cat. It should also override the abstract method of Animal, speak, to return the String, "meow" 25. Create an object of type Cat. 26. What is recursion in Java? 27. The condition that ends a recursive method is called the Without it recursion occurs and causes this type of exception 28. Trace through this method for t(4). What does it evaluate to? Precondition n>-1 public int t (int n) if (n -1n-2) return 2* n; else return t(n-1) - t (n-2); 29. Write the program Test. It contains a recursive method, mystery, which returns the value of this function: F(n) 3, when n1 F(n) 3*f(n-1) otherwise
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
