Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Sample Questions

The following questions are meant to give you an idea of the format of questions you could see on the
quiz. These sample questions are not meant to be indicative of all possible types of questions that could
be asked nor are they indicative of all content that will be on the quiz. The best thing you can do for
yourself is to study and practice the concepts covered in the topics identified above.

1. Using course terminology, explain if a subclass inherits its superclass’ constructor. Your
explanation should specify which type of items are and are not inheritable.

2. Assume you have created an inheritance hierarchy with classes of Employee, Engineer, and
Architect. Each class has a hello() method. Based on the implementation code provided below,
could each of the following code blocks be added to the end of the main method? Why or why
not? Explain you answer using course terminology.

1) JOptionPane.showMessageDialog(null, getHelloMessage(emp1));
2) JOptionPane.showMessageDialog(null, getHelloMessage(eng1));
3) JOptionPane.showMessageDialog(null, getHelloMessage(arc1));

1 //Implementation Class
2 import javax.swing.JOptionPane;
3 public class Question{
4 public static void main(String[] args){ 5
Employee emp1 = new Employee(); 6 Engineer eng1 =
new Engineer(); 7 Employee arc1 = new Architect();
8
9 //Code would be added here
10 }
11
12 public static String getHelloMessage(Employee e){ 13
return e.hello();
14 }
15 }
Page 2 of
2 Copyright ©2021 John Bono, Ph.D. All rights reserved.

You might also like