emmanuelsmidterm.docx.pdf - PENNSTATEHARRISBURG Fall2015 MIDTERMEXAM Instructor:JaneS.Kochanov([email protected] STUDENTEMAIL ..A

emmanuelsmidterm.docx.pdf - PENNSTATEHARRISBURG Fall2015...

This preview shows page 1 out of 5 pages.

Unformatted text preview: PENN STATE HARRISBURG School of Business Administration IST 311 Object­Oriented Design and Software Applications Fall 2015 MID­TERM EXAM Instructor: Jane S. Kochanov (Do Not Enter Name) [email protected]_______ STUDENT EMAIL Below are the exam questions. Please read each question completely. As you type please change your font to distinguish the question from your answer. 1. All of the parts of question 1 are related. a. Write a Java statement that creates a ​ JPanel​ named ​ accountPanel​ . (1 pt) JPanel accountPanel = new JPanel(); b. Write a Java statement that assigns the ​ BorderLayout​ manager to the ​ JPanel named ​ accountPanel​ . (1 pt) JPanel accountPanel = new JPanel(new BorderLayout); c. Write a Java Statement that creates a ​ JLabel​ named ​ accountNumber​ with the label “Account Number”. (1 pt) JLabel accountNumber = new JLabel(“Account Number”); d. Write a Java Statement that creates a ​ JTextField​ named ​ account​ with a size of 8 characters. (1 pt) JTextField account = new JTextField(8); e. Write a Java statement that adds the ​ JLabel​ ​ accountNumber​ and the JTextField ​ account​ to the ​ JPanel ​ accountPanel​ .​ Remember that accountPanel​ has the ​ BorderLayout​ . (2 pts) accountPanel.add(accountNumber, “east”); accountPanel.add(account, “center”); f. Write a Java statement that creates a ​ JButton​ named ​ save​ with an appropriate label. (1 pt) JButton save = new JButton(“save”); IST 311 Object­Oriented Design MID­TERM EXAM ­ Fall 2015 Page 2 g. Write a Java statement that creates an ​ event listener​ for the ​ JButton​ named save​ . (1 pt) save.addActionListener(this); h. Write a Java statement that adds the ​ JButton ​ save​ to the ​ JPanel accountPanel​ . (1 pt) accountPanel.add(save, “south”); 2. How many columns and how many rows will be in the frame that is formatted according to the following statement? (1 pt) setLayout(new GridLayout(6, 2, 2, 2); there will be 2 columns and 6 rows 3. A large software system is a capital investment in most companies. As a result, these systems must be changed periodically as new requirements are presented. Define, explain, and contrast the terms ​ maintenance​ , ​ evolution​ , and ​ preservation​ as related to software development. (3 pts) A software system is an investment and as such it would be meaningless to throw away an existing system every time the requirements change. Originally, object-oriented technology was considered the solution to software maintenance when the question arose that: what happens to the software when it has to be changed if new technologies keep being introduced. Software evolution occurs when the previous development was successful; being able to adapt to constantly changing user requirements. Software preservation is continuing the use of abstract means to keep a rotting piece of software in operation. 4. List and explain the four major elements of Object­Oriented Programming. (4 pts) Encapsulation - the secrecy of data implementation by limiting access to accessors and mutators Data Abstraction - used to decompose complex systems into smaller components Polymorphism - having multiple methods with all the same name, but different functionality Inheritance - is a way to reuse code of an existing object or establish code of an existing object 5. Suppose that you have the following class definition: public class One { private int x; private int y; IST 311 Object­Oriented Design MID­TERM EXAM ­ Fall 2015 Page 3 public One( int u, int v) { x = u; y = v; } public void printOutput ( ) { System.out.println ( x + “ “ + y); } public int getX( ) { return x; } public int getY( ) { return y; } } Consider the second class definition: public class Two extends One { private int z; public Two ( int a, int b, int c) { // This method should make x = a, y = b, z = c } public void printOutput ( ) { // Output the values of x, y, and z to console. } } a. Write the method ​ Two​ of the class ​ Two​ as described in the method comment. (2 pts) x=a y=b IST 311 Object­Oriented Design MID­TERM EXAM ­ Fall 2015 Page 4 b. Write the method ​ printOutput​ of the class ​ Two​ as described in the method comment. (2 pts) a+c+b 6. The Baltimore Public Marina needs to store information about all boats in the marina, including values for such things as the boat’s state registration number, length, manufacturer, and model year. Draw a UML Class Diagram for the Boat class. (3 pts) Public class marina Private registration number Private length Private manufacturer Private model year 7. This question is related to question 6 above. There are special types of boats. Each boat has the common attributes that are part of question 6. There are special types of boats such as sailboats and powerboats. A sailboat has a keel depth (sometimes called draft), a number of sails, and a motor type which can be none, inboard, or outboard. A powerboat does not have sails and its keel depth is unimportant. However, a powerboat might have several engines (you need to know the number of engines) and their fuel type, either gas or diesel. What technique of Object­Oriented programming is this question describing? Why is this an important concept of Object­Oriented programming? This might be polymorphism which is important to OOP because it allows multiple methods with the same name but different functionality 8. Write a private method called ​ setEditMenu( )​ . In this method, create a menu named "​ Edit​ " which has the items "​ Cut​ ", "​ Copy​ ", "​ Paste​ ", and "​ Delete​ " in it. Add each item to the menu. Create an ActionListener for each item on the menu. Do not write the source code that the ActionListener would execute. (5 pts) setEditMenu() { JMenu Edit = new JMenuBar(“edit”); IST 311 Object­Oriented Design MID­TERM EXAM ­ Fall 2015 JMenuItem cut = new JMenuItem(“cut”); JMenuItem copy = new JMenuItem(“copy”); JMenuItem paste = new JMenuItem(“paste”); JMenuItem delete = new JMenuItem(“delete”); For(int i=0, i<3; i++) {add.ItemListener(this);) } Page 5 ...
View Full Document

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture