Free Essay

Object Oriented Programming Exam

In:

Submitted By ukaa
Words 731
Pages 3
SAMPLE QUESTION PAPER

Object Oriented Programming using Java

SEMESTER 1& 2

Question 1 (25 marks)

a) Discuss the syntax, purpose and application, with an example for each, of the following:

i. if ii. while iii. for iv. switch (4 x 5 marks = 20 marks)

b) Write an independent Java method that accepts three sides of a triangle, say a, b and c and returns

“Equilateral” if all the three sides are equal, “Isosceles” if any two sides are equal “Scalene” otherwise. (5 marks)
Question 2 (25 marks)

a) Write an independent Java method that accepts an integer and returns true if it is a prime number, false otherwise. An integer is said to be prime if it is divisible by 1 and itself only. (9 marks)

b) Write an independent Java method that accepts an array of integers and returns the smallest of them. (8 marks)

c) Write a Java program to accept 10 integers and print the sum of numbers divisible by 5.
(8 marks)

Question 3 (25 marks)

a) Write a Java program to print the sum, average, maximum and minimum of 10 numbers. All numbers must be read from the user.
(8 marks)
b) What are formal and actual arguments? Explain with a sample program how they work in Java.
(8 marks)

c) Write a Java program to print first n Fibonacci sequence of numbers. The first two numbers of the sequence are 0 and 1; next number is the sum of the previous numbers.
(9 marks)

Question 4 (25 marks)

The assessments for the subject Object Oriented Programming consists of: • one assignment mark worth 30% of final assessment, plus • one examination mark work 70% of final assessment.

The subject instructor needs a program that accepts a student identification number and marks for the two assessments above as input, and determines and outputs the final mark and grade for each student. The grade awarded is based on the following scheme:

final mark letter grade less than 60 F greater than 60, less than 70 D greater than 70, less than 80 C greater than 80, less than 90 B greater than 90, less than or equal to 100 A

The assessment marks are of type integer, and student identification numbers are four-digit integers. The lecturer also wants the distribution of grades to be printed at the end.

Assume that the class KeyboardReader is available to you and use it to allow the user to enter the assessment mark. All results should be shown on the computer's screen.

Question 5 (25 marks)

This question requires you to implement and test a user-defined Java class. It requires similar work to that done with the sample classes covered in this subject

Objects of the class you are to create represent Appliance and, in general, Appliance objects are simulations of real appliances, which might be used by rental shops.

Analysis

The state of an Appliance object should include:

• Name ( a String) • Model ( a String) • Price (a double) The behavior of an Appliance object should include: • A method to initialise the Appliance objects with its Name, Model and price. • A reader method for each of the attributes. A reader method is a method that returns the value of the corresponding attribute. • A writer method for each of the attributes. The writer method for price should not allow the price to become negative. A writer method is a method that accepts a value as a parameter and sets the attribute value.
Design
Write the Appliance class in a file called Appliance. java and make sure that the class itself starts with:

class Appliance
{
Arguments must be used for any inputs to the Appliance writer methods. Any values output from the methods must be made available via a return value. Do not have any standard output (System.out.println) statements in any of the Appliance methods.
Question 6 (25 marks)

a) Write a simple applet with two buttons increase and decrease, and a text field. The default text field value will be 0. When a user clicks increase, the value in the text field increases by 1. When the user clicks decrease, the value is decreased by 1.
(12 marks)

b) Write a Java program, which defines an array of 10 elements and reads real numbers from the user. Write a separate method to print the output in ascending order. (13 marks)

Similar Documents

Free Essay

Management Lessons from Mayo Clinic

...PRINCIPLES OF PROGRAMMING LANGAUAGES Sub Code: IA Marks: Hrs/Week: 04 Exam Hours: 03 Total Hrs: 42 Exam Marks: 100 UNIT I 1. Introduction 4 Hrs Toward higher level languages, Programming paradigms, Language implementation: Bridging the gap, Expression notations, Abstract syntax trees. 2. Types : Data Representation 6 Hrs Elementary data types – Data objects, Variables and Constants, Data types, Declarations, Type checking and type conversion. Numeric data types, Enumerations, Booleans, characters. Structural data types- Structured data objects and data types, Specification of data structure types, Implementation of data structure types, Vectors and arrays, Records, Type equivalence. UNIT II 3. Imperative Programming 6 Hrs Basic statements, Structured sequence control, Handling special cases in loops, Programming with invariants, Proof rules for partial correctness. Procedure activations – simple call-return subprograms, Parameter passing methods, Scope rules for names...

Words: 403 - Pages: 2

Free Essay

114 Outline

...3491 ISIT114 Object Oriented Programming Subject Outline Spring Session 2014 Consultation Times: Subject Coordinator Telephone Number: Email: Location: Dr. Sifer's consultation times during session: Day Monday Wednesday Subject Organisation: Session: Credit Points Contact hours per week: Lecture Times & Location: Tutorial Day, Time and Location can be found at: Spring Session, Wollongong Campus 6 credit points 2 Hours Lec, 2 Hours Lab Wed 10:30-12:30 67-104 http://www.uow.edu.au/student/timetables/index.html Time 9:00 - 11:00am 1:30 - 3:30pm Dr Mark Sifer 4221 4919 msifer @uow.edu.au 39.219 Students should check the subject's web site regularly as important information, including details of unavoidable changes in assessment requirements will be posted from time to time via MOODLE http://www.uow.edu.au/student/ . Any information posted to the web site is deemed to have been notified to all students. Subject Description: The aims of this subject are to consolidate and extend student's knowledge and skills in structured programming and to introduce them to the concepts and practice of object oriented programming. To achieve this aim the subject will provide students with an opportunity to develop further programming skills and good coding style; develop skills in using the object-oriented concepts of inheritance, encapsulation, construction, access control, overloading and messaging; develop and display competency in the design and implementation of object-oriented programs to...

Words: 2995 - Pages: 12

Free Essay

This Is a Syllabus

...Meet Karel the Robot Wednesday 25 Programming with Karel Control structures in Karel 27 Friday Problem-solving in Karel Program decomposition The idea of an algorithm 30 Read: Karel, Chapters 1-3 Read: Karel, Chapters 4-6 October 2 4 Control statements Boolean expressions Introduction to Java Variables, values, and types Classes and objects Arithmetic expressions The Program class hierarchy Read: Java, Chapters 1-2 7 Methods Using parameters Read: Chapter 3 9 More parameters Pseudorandom numbers The RandomGenerator class Read: Chapter 4 Due: Assignment #1 11 Creating classes Stylistic expectations Using javadoc Read: Chapter 5 14 Read: Chapter 6 16 18 Character data The Java String class The acm.graphics package More graphics The collage graphics model Event driven programming Read: Chapter 9.1-9.3 Due: Assignment #2 21 Read: Chapter 9.4 Read: Chapter 10.1–10.4 23 Read: Chapter 8.1-8.4 25 File processing Exception handling String manipulation Objects and memory Problem-solving with strings More on parameter passing Read: Chapter 8.5 Read: Chapter 7 Due: Assignment #3 Read: Chapter 12.4 –2– Monday 28 Arrays and ArrayList 30 Arrays and ArrayList (continued) Wednesday Friday November 1 Belated midterm recovery day (No class) Read: Chapter 11.1-11.8 Tuesday, October 29th 7:00-9:00pm: Midterm 4 6 Debugging strategies Java collections framework The HashMap class Iterators Object-oriented design Read: Chapter 13 13 Component...

Words: 409 - Pages: 2

Premium Essay

Syllabus

...Hours 4 3 4 3 4 3 Credit 4 2 4 2 4 2 University External Marks 50 50 50 CSE361 CSE313 CSE363 AS301 EC316 EC366 EC317 EC367 Data Structures (Practical) Peripheral Devices & Interfaces Hardware Lab (Practical) Engineering Mathematics – III Digital Electronics Digital Electronics (Practical) Microprocessors Microprocessors (Practical) 0 3 0 3 3 0 3 0 15 0 1 0 1 1 0 1 0 5 3 0 2 0 0 2 0 2 09 3 4 2 4 4 2 4 2 29 2 4 1 4 4 1 4 1 25 50 50 50 50 250 Internal Total Sessional Marks 50 50 50 50 50 50 50 50 50 450 100 50 100 50 100 100 50 100 50 700 7. 8. Total ASC405 CSE 415 Analysis & Design of Algorithms Analysis & Design of Algorithms (Practical) Database Management System Database Management System (Practical) Object Oriented Programming Object Oriented Programming (Practical) Cyber Law & IPR Computer Architecture & Organization Internal Total Sessional Marks 50 100 50 50 50 50 50 50 100 50 100 50 3 3 15 0 1 4 0 0 9 3 4 28 3 4 25 50 50 250 50 50 400 100 100 650 2 Scheme of Examination of B.E. in Computer Science & Engineering Third Year - Fifth Semester Sr. Paper Subject Title Scheme of Teaching Univesity Internal Sessional Code External L T P Hou Credit Marks Total Marks rs s 1. CSE511 Operating System 3 1 0 4 4 50 50...

Words: 14784 - Pages: 60

Free Essay

Object-Oriented Analysis and Design

...Generic Exam: Object-Oriented Analysis and Design Time: 2.5 hours Marking: 100 marks, plus 10 marks for the bonus question. Purpose This purpose of this generic exam is to allow you to see what the real final exam will look like, and the relative weighting in terms of marks. The only significant difference between this generic exam and the final one is that the latter will include a specific case study. Exam Process This examination is composed of multiple sections. Each subsequent section relies upon standard solutions from the previous sections. You are required to submit your section answers—on completion—to the examination coordinator, and trade it for the standard solution. Use the provided standard solution as the basis for your subsequent work. On completion of the examination, hand in the entire set of standard solutions. Do not reveal or discuss the standard solutions, either during or after the examination. Marking ▪ Please note that the use case questions have the least marks, since they are relatively straightforward and not an object-oriented skill. In contrast, the questions on responsibility assignment, patterns, and design of collaborations have the most marks, since these are the most important object-oriented design skills. Evaluation Objectives ▪ Ability to identify primary use cases and record them in expanded, essential form. ▪ Ability to identify outstanding concepts, associations, and attributes and...

Words: 688 - Pages: 3

Free Essay

20480 Course Reference

...The Microsoft course 20480: Programming in HTML5 with JavaScript and CSS is a five day intensive class on HTML, CSS, and JavaScript. If you know nothing coming into the class it will be like drinking from a fire hydrant. I’m not sure why the class has HTML in the title as it only covers HTML for about 10 of the 500 pages. So, you really should have some decent HTML experience prior to the class. That being said, there are so so, so many resources for information on these three topics I thought it would be nice to break it down. In addition, many students take this class in preparation for SharePoint. I will also include specific SharePoint references, as … well …. SharePoint currently rules the world  Module 1: Overview of HTML and CSS W3Schools Heather Solomon Styles for SharePoint CSS Selector Reference Chapter 2: Creating and Styling HTML Pages F12 Developer Tools – Introduction F12 Developer Tools Module 3 JavaScript in 12 minutes JSON vs. XML Regular Expressions reference Module 4 HTML Forms Tutorial – Video Regular Expressions reference CustomValidity – Video Module 5 JQuery tutorial – video Sending and Receiving Data using JQuery General References JQuery Selectors Module 6 Pseudo-classes Pseudo-elements Module 7 JavaScript Object Oriented Programming – book OOP in JavaScript – book JavaScript Objects – video Module 8 FileReader Explained FileReader Example Drag and Drop Tutorial – video GeoLocation Video F12 Developer Tools video How to...

Words: 287 - Pages: 2

Free Essay

Vivek

...DIPLOMA IN COMPUTER APPLICATIONS (PGDCA) (Effective From July 2011 Session) SEMESTER -I Subject Code Subject Name Scheme L 1PGDCA1 1PGDCA2 1PGDCA3 1PGDCA4(A) 1PGDCA4(B) Fundamentals of Computers & Information Technology Introduction to Operating Systems (Dos, Windows, Linux) PC Packages Elective - 1 Foxpro MS-Access 4 4 1 3 T P Theory Paper 80 80 Internal Evaluation 20 20 Practical Exams Total Marks 100 100 4 4 1 3 3 80 80 20 20 25 25 125 125 Semester Total 450 (*L-Lecture, T-Tutorial, P-Practical) SEMESTER –II Subject Code Subject Name Scheme L 2PGDCA1 2PGDCA2 2PGDCA3 2PGDCA4(A) 2PGDCA4(B) 2PGDCA5 System Analysis and Design Programming with Visual Basic.NET Internet & E-Commerce Elective - 2 OOPs & Programming with C++ Financial Accounting with Tally Project Work 4 4 4 4 T 1 P 3 3 3 Theory Paper 80 80 80 80 Internal Evaluation 20 20 20 20 Practical Exams Total Marks 100 125 100 125 25 1 25 4 100 Semester Total 550 General Instructions: 1. For passing the subject examination minimum 40% marks must be separately scored in Theory Paper, Practical Exams and Internal Evaluation in the subject. 2. For passing the semester, minimum aggregate marks must be 45% in the semester. Course : PGDCA Sub Code : 1PGDCA1 Semester: I Subject Name : Fundamentals of Computers & Information Technology Workshops Total Hours Field Visits Practical’s UNIT–I Brief History of Development of Computers, Computer System Concepts, Computer...

Words: 4021 - Pages: 17

Free Essay

Chap 3

...Chapter 3 – Conceptual Design: An Overview of Methodologies, Models and Notations CHAPTER OBJECTIVES (YOU SHOULD BE ABLE TO): 1. Define and describe a methodology. 2. Define and describe traditional, structured analysis & design, information modeling, and object-oriented methodology classifications. 3. Define and describe a Data Flow Diagram (DFD) and an Entity-Relationship Diagram (ERD). 4. Define and describe attributes, operations and relationships in an object-oriented methodology. 5. Define and describe the foundational characteristics of an object-oriented methodology. 6. Describe two classic information systems development challenges and their potential resolution. 7. Discuss Classification Theory and its relationship with object-oriented methodologies. 8. Describe Rational Corporation's Unified Software Development Process. 9. Define parallelism, substitution and omission. 10. Describe the Unified Modeling Language (UML) and describe Use Case, Class Diagram and Interaction Diagram. 11. Describe a simplistic object-oriented methodology for applying and using the UML. 12. Describe the foundational characteristics of the UML’s Class Diagram DESIGN A generic systems development life cycle (SDLC) was presented in an earlier chapter. You may recall that the purpose for this version of a SDLC was to give you a simplified way of sequentially studying the activities that are utilized to produce software-intensive information systems. In reality the SDLC...

Words: 13243 - Pages: 53

Premium Essay

C++ Programming

...C++ PROGRAMMING: FROM PROBLEM ANALYSIS TO PROGRAM DESIGN FIFTH EDITION D.S. MALIK Australia  Brazil  Japan  Korea  Mexico  Singapore  Spain  United Kingdom  United States C++ Programming: From Problem Analysis to Program Design, Fifth Edition D.S. Malik Executive Editor: Marie Lee Acquisitions Editor: Amy Jollymore Senior Product Manager: Alyssa Pratt Editorial Assistant: Zina Kresin Content Project Manager: Matthew Hutchinson Art Director: Faith Brosnan Print Buyer: Julio Esperas Cover Designer: Roycroft Design/ www.roycroftdesign.com Cover Photo: ª Guntmar Fritz/Masterfile Proofreader: Green Pen QA Indexer: Elizabeth Cunningham Compositor: Integra ª 2011 Course Technology, Cengage Learning ALL RIGHTS RESERVED. No part of this work covered by the copyright herein may be reproduced, transmitted, stored or used in any form or by any means graphic, electronic, or mechanical, including but not limited to photocopying, recording, scanning, digitizing, taping, Web distribution, information networks, or information storage and retrieval systems, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the publisher. For product information and technology assistance, contact us at Cengage Learning Customer & Sales Support, 1-800-354-9706 For permission to use material from this text or product, submit all requests online at www.cengage.com/permissions Further permissions questions can be...

Words: 11776 - Pages: 48

Free Essay

N Mdnkqwr Jedqwjeqwkoeqw Asmdnkqwe

...Course: Object-Oriented Programming & Design MCS 2nd Mid Term Exam Total Marks: 70 Total Time: 90 Minutes May 22, 2015 1. Write a program that contains a class Faculty and a class Course. The Faculty class should have data about the first name, last name, and the name of a course allocated to the faculty. The faculty class contains the set and get member functions for first name and last name, and a print function that prints the name and course of the faculty. The Course class contains a course code of type integer and the name of the course, set and get member functions for these data members, and a print function that prints the course code and course name. Explain the steps properly by writing comments. (5) a. Your program should have separate interface and implementation files. (10) b. The constructor of the Faculty class takes constant parameters passed to it by reference. Explain what difference does it make. (5) c. Which member functions should be declared as constant and why. (3) d. The Constructor of the Course class should take the default arguments of course code = 101 and Course Name = Introduction to Computing. (2) e. Validate that the course name should not exceed more than 30 characters. (5) f. In your main function declare an object of the Course class to initialise the data members to a course name and its course code. (2) g. Your main function should print the first name, last name, course code and course name assigned to the faculty...

Words: 385 - Pages: 2

Free Essay

Java Basics

...1 Learn Java/J2EE core concepts and key areas With Java/J2EE Job Interview Companion By K.Arulkumaran & A.Sivayini Technical Reviewers Craig Malone Stuart Watson Arulazi Dhesiaseelan Lara D’Albreo Cover Design, Layout, & Editing A.Sivayini Acknowledgements A. Sivayini Mr. & Mrs. R. Kumaraswamipillai 2 Java/J2EE Job Interview Companion Copy Right 2005-2007 ISBN 978-1-4116-6824-9 The author has made every effort in the preparation of this book to ensure the accuracy of the information. However, information in this book is sold without warranty either expressed or implied. The author will not be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. Please e-mail feedback & corrections (technical, grammatical and/or spelling) to java-interview@hotmail.com First Edition (220+ Q&A): Dec 2005 Second Edition (400+ Q&A): March 2007 3 Outline SECTION DESCRIPTION What this book will do for you? Motivation for this book Key Areas index SECTION 1 Interview questions and answers on: Java Fundamentals Swing Applet Performance and Memory issues Personal and Behavioral/Situational Behaving right in an interview Key Points SECTION 2 Interview questions and answers on: Enterprise Java J2EE Overview Servlet JSP JDBC / JTA JNDI / LDAP RMI EJB JMS XML SQL, Database, and O/R mapping RUP & UML Struts Web and Application servers. Best practices and performance considerations. Testing and deployment. Personal and...

Words: 23255 - Pages: 94

Free Essay

Java Programming

...A Programmer’s Guide to Java™ SCJP Certification Third Edition This page intentionally left blank A Programmer’s Guide to Java™ SCJP Certification A Comprehensive Primer Third Edition Khalid A. Mughal Rolf W. Rasmussen Upper Saddle River, New Jersey • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sidney • Tokyo • Singapore • Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United...

Words: 15086 - Pages: 61

Premium Essay

Java for Dummies

...Programming Languages/Java ™ Jumpin’ Java! The bestselling Java beginner’s book is now fully updated for Java 7! Open the book and find: ava J • Definitions of the many terms you’ll encounter ® • The grammar of Java • How to save time by reusing code • All about if, for, switch, and while statements • An overview of object-oriented programming • Building blocks — learn to work with Java classes and methods and add comments • Hints about handling exceptions • How to write Java applets ® • The Java scoop — get an overview of Java, the enhancements in Java 7, and the software tools you need • Get loopy — understand the value of variables and learn to control program flow with loops or decision-making statements 5th Edition 5th Edition Java Java, the object-oriented programming language that works on almost any computer, is what powers many of those cool multimedia applications. Thousands have learned Java programming from previous editions of this book — now it’s your turn! Whether you’re new to programming or already know a little Visual Basic or C++, you’ll be doing Java in a jiffy. g Easier! Making Everythin • Ten ways to avoid mistakes • Class it up — explore classes and objects, constructors, and subclasses, and see how to reuse your code • A click ahead — experiment with variables and methods, use arrays and collections to juggle values, and create programs that respond to mouse clicks Learn...

Words: 34460 - Pages: 138

Premium Essay

Cis 247c Ilab 4 of 7: Composition and Class Interfaces

...CIS247C iLab 4 of 6: Composition and Class Interfaces/Abstract Class Click this link to get the tutorial http://goo.gl/Fu6hE | | | | Connect to the iLab here. | | | | | | | Submit your assignment to the Dropbox located on the silver tab at the top of this page.(See Syllabus "Due Dates for Assignments & Exams" for due dates.) | | i L A B O V E R V I E W | | Scenario and Summary | | The objective of the lab is to modify the Employee class to demonstrate composition and a class interface. An employee typically has benefits, so we will make the following changes: 1. Create a Benefits class. 2. Integrate the Benefit class into the Employee class. 3. Create an iEmployee abstract class to guarantee that calculatePay is implemented in the Employee class. A tutorial on interfaces can be downloaded here. Deliverables | Due this week: * Capture the Console output window and paste it into a Word document. * Zip the project folder files. * Put the zip file and screen shots (Word document that contains programming code and screen shots of program output) in the Dropbox. | i L A B S T E P S | | STEP 1: Understand the UML Diagram | | Employee - firstName : string - lastName : string - gender : char - dependents : int - annualSalary : double - static numEmployees : int = 0 +benefit : Benefit +Employee() +Employee(in fname : String, in lname : String, in gen : char, in...

Words: 1103 - Pages: 5

Premium Essay

Cis 247c Ilab 4 of 7: Composition and Class Interfaces

...CIS247C iLab 4 of 6: Composition and Class Interfaces/Abstract Class Click this link to get the tutorial http://goo.gl/Fu6hE | | | | Connect to the iLab here. | | | | | | | Submit your assignment to the Dropbox located on the silver tab at the top of this page.(See Syllabus "Due Dates for Assignments & Exams" for due dates.) | | i L A B O V E R V I E W | | Scenario and Summary | | The objective of the lab is to modify the Employee class to demonstrate composition and a class interface. An employee typically has benefits, so we will make the following changes: 1. Create a Benefits class. 2. Integrate the Benefit class into the Employee class. 3. Create an iEmployee abstract class to guarantee that calculatePay is implemented in the Employee class. A tutorial on interfaces can be downloaded here. Deliverables | Due this week: * Capture the Console output window and paste it into a Word document. * Zip the project folder files. * Put the zip file and screen shots (Word document that contains programming code and screen shots of program output) in the Dropbox. | i L A B S T E P S | | STEP 1: Understand the UML Diagram | | Employee - firstName : string - lastName : string - gender : char - dependents : int - annualSalary : double - static numEmployees : int = 0 +benefit : Benefit +Employee() +Employee(in fname : String, in lname : String, in gen : char, in...

Words: 1103 - Pages: 5