Sample questions: 1) What does the super keyword represents and where can it be used? Give a code example of a superclass and subclass. Be sure to make all the instances variables of the super class...




Sample questions:



1)What does the super keyword represents and where can it be used? Give a code example of a superclass and subclass. Be sure to make all the instances variables of the super class


private

. Include at least one constructor in each class and ensure that the constructor of the subclass calls the constructor of the superclass. Also include a


toString


method in both classes that returns the values of the instance variables with appropriate labels. Ensure that the


toString


method of subclass calls the


toString


method of the superclass so that the string returned contains the values of all the inherited instance variables.




2)
What is exception propagation? Give a code example of a class that contains at least two methods, in which one method calls another. Ensure that the subordinate method will call a predefined Java method that can throw a checked exception. The subordinate method should not catch the exception. Explain how exception propagation will occur in your example.



3)
Give a code example of a program that creates a GUI with at least one button and several textfields. Some of the textfields should be for input and others for output. Make the output textfields uneditable. When the button is clicked, the input fields should be read, some calculation performed and the result displayed in the output textfield(s).



4)
Radio buttons and check boxes are two of many different kinds of components that can be included in a graphical user interface. How are they similar and how are they different? Which kind requires grouping? Give a code example of an application where each of these two types of GUI components might be useful.



5)
Provide a recursive definition of some sequence of numbers. Choose one different from that of any posted thus far. Write a recursive method that given
n, computes the
nth term of that sequence. Also provide an equivalent iterative implementation. How do the two implementations compare? Provide code example to explain your answers




6)
Give a code example of a program that uses the nongeneric version of a class from the STL and the equivalent program that uses the generic version. How do the two implementations differ? Why is having the syntax of generics better?



7)
Array lists and linked lists are both implementations of lists. Give an example of a situation where an array list would be the better choice and one where a linked list would. Explain the reasons in each case.

Oct 27, 2019
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here