Programming Fundamentals II (C++ II) Final Exam June 17 th, Sun, 2007

Similar documents
6.096 Introduction to C++

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

Exercises 1. class member { int membernum = 25; float memberpay; public void Input(cin >> membernum >> memberpay); void Output; }

C++ 8. Constructors and Destructors

Object Oriented Programming COP3330 / CGS5409

I Mid Semester May 2012 : Class XII : Computer Science Max Mark 50 : Time 2 Hrs. 1. a) What is macro in C++? Give example 2

OOP THROUGH C++(R16) int *x; float *f; char *c;

ECE 462 Object-Oriented Programming using C++ and Java Design Issues and Multiple Inheritance in C++

For Teacher's Use Only Q No Total Q No Q No

Darrell Bethea June 6, 2011

A506 / C201 Computer Programming II Placement Exam Sample Questions. For each of the following, choose the most appropriate answer (2pts each).

CSCI 102 Fall 2010 Exam #1

LAB 4.1 Relational Operators and the if Statement


public : int min, hour ; T( ) //here constructor is defined inside the class definition, as line function. { sec = min = hour = 0 ; }

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2, SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN, U.O.P. UNIT-2

Stacks and Queues. Chapter 8 (Cont.)

CSCI 1370 APRIL 26, 2017

CSCE Practice Midterm. Data Types

CHAPTER 9 INHERITANCE. 9.1 Introduction

CSCE 2004 Midterm Exam Spring 2017

Use the template below and fill in the areas in Red to complete it.

L4: Inheritance. Inheritance. Chapter 8 and 10 of Budd.

Data type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples:

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak

Scheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C

CSci 1113 Final. Name: Student ID:

CSci 1113 Midterm 1. Name: Student ID:

KENDRIYA VIDYALAYA TIRUMALAGIRI,SECUNDERABAD UNIT TEST II

Exam Duration: 2hrs and 30min Software Design

Object-Oriented Programming (OOP) Fundamental Principles of OOP

CSC1322 Object-Oriented Programming Concepts

C C++ C++! "# C++ ++

Hong Kong University of Science and Technology COMP151: Object Oriented Programming

Lab 12 Object Oriented Programming Dr. John Abraham

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class

Midterm Exam 5 April 20, 2015

Constructors and Destructors. Chapter 6

Question 1 Consider the following structure used to keep employee records:

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2017

IUE Faculty of Engineering and Computer Sciences Spring Semester

CS250 Final Review Questions

Example : class Student { int rollno; float marks; public: student( ) //Constructor { rollno=0; marks=0.0; } //other public members };

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

Comp151. Inheritance: Initialization & Substitution Principle

This test is OPEN Textbook and CLOSED notes. The use of computing and/or communicating devices is NOT permitted.

Chapter-6 Classes and Objects. stud.execute(); getch();} Output:

THE NAME OF THE CONSTRUCTOR AND DESTRUCTOR(HAVING (~) BEFORE ITS NAME) FUNCTION MUST BE SAME AS THE NAME OF THE CLASS IN WHICH THEY ARE DECLARED.

Object Oriented Programming Using C++ Mathematics & Computing IET, Katunayake

ITEC LAB 8- Task1- Solution INHERITANCE ASSIGNMENT:

B.Sc. (Hons.) Computer Science I B.Sc. (Hons.) Electronics. (i) Runtime polymorphism and compile time polymorphism

System Design and Programming II

Object Oriented Programming 2012

- HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM

CS250 Final Review Questions

Data Structures using OOP C++ Lecture 3

Introduction to Object-Oriented Programming with C++

Midterm Exam #2 Spring (1:00-3:00pm, Friday, March 15)

C:\Temp\Templates. Download This PDF From The Web Site

This exam is open book. Each question is worth 3 points.

Islamic University of Gaza Faculty of Engineering Computer Engineering Department

Object Oriented Programming CS250

Fall CS 101: Test 2 Name UVA ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17.

Exercise1. // classes first example. #include <iostream> using namespace std; class Rectangle. int width, height; public: void set_values (int,int);

Do not write in this area A.1 A.2 A.3 A.4 A.5 A.6 B.1 B.2 B.3 TOTAL. Maximum possible points:

VIRTUAL FUNCTIONS Chapter 10

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

INTERNATIONAL INDIAN SCHOOL, RIYADH. Ch 1 C++ Revision tour

An Object Oriented Programming with C

Programming, numerics and optimization

Introduction to Inheritance

Data Types & Variables

CSCE Practice Midterm. Data Types

Short Notes of CS201

CS 216 Exam 1 Fall SOLUTION

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

Object Oriented Programming CS250

2 2

Review: C++ Basic Concepts. Dr. Yingwu Zhu

I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK a) What is the difference between Hardware and Software? Give one example for each.

CS201 - Introduction to Programming Glossary By

C++_ MARKS 40 MIN

(a) Differentiate between a call by value and call by reference method.

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

REVIEW EXERCISES. Draw an inheritance diagram that shows the relationships between these classes.

Programming in C++: Programming Test-1

Module 1. C++ Classes Exercises

OBJECTS. An object is an entity around us, perceivable through our senses. Types of Object: Objects that operate independently.

Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team

CS304 Object Oriented Programming Final Term

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Session Chapter 4: Classess & Object

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Program template-smart-pointers-again.cc

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)

CSCI 101L - Data Structures. Practice problems for Final Exam. Instructor: Prof Tejada

Arrays in C++ Instructor: Andy Abreu

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

CSci 1113 Final. Name: Student ID:

Programming in C++ The manager of a company. Lecture Notes 6. Functions (Procedures) 4/24/2018. he he he. Does Does Does

Transcription:

Programming Fundamentals II (C++ II) Final Exam June 17 th, Sun, 2007 NAME:...Number:... Question 1 Define class section that has the following attributes: coursename, coursenumber as integer, credithours as integer, Size (total number of student) as integer, and List as a list of all students IDs. Since the total number of students in a section is variable, List has variable length. Define a constructor for this class that will initialize each of the class attributes. Define the class destructor. Hint: a student ID can be stored in long integer.

Question 2 Define class Book which has two data members, pages (which is an integer that represents the number of pages) and ISBN (which is an integer that represents the ISBN or ID of the book). Write a constructor which uses two input parameters to initialize the data members. Define print as a method that will print out ISBN and pages of the object. Define TextBook as a class that inherits all attributes and methods of Book class. In addition, TextBook has data member price as float (which represents the price of the book). Write a constructor which uses three input parameters to initialize pages, ISBN and price, by calling the constructor of the parent (or base) class. For this class TextBook Define increase_cost as a method that will increase the price of the book by value x. Also, Define print as a method that will print out all attributes of a Textbook object (pages, ISBN, and price), the method should do this by calling print method of the parent class.

Question3 What is the output of the following code A. #include <iostream.h> class A{ protected: int x; public: A() {x=90;} A(int x1) {x=x1;} void print() {cout<<x<<endl;}}; class B:public A{ public: B(){cout<<"In B1"<<endl;} B(int x1):a(x1) {cout<<"in B2"<<endl;}}; void main(){ A a1; B b1; B * b2 = new B(200); a1.print(); b1.print(); b2->print(); } B. #include <iostream.h> class A{ int *a; public: A(int x, int y) {a=new int[2]; a[0]=x; a[1]=y;} void print() {cout<<a[0]<<a[1];} }; void main(){ A a1(10,20); A a2(0,0); a2=a1;a1.print(); a2.print(); } C. void main(){ int a[3]={20,30,40}; int *p=&a[0]; cout<<*p<<*(a+1); p++; *p=*(a+1)+10; cout<<a[0]<<a[1]<<a[2]; }

Question 4 Assume that you have the following class: class Student{ private: int ID; char *name; int grades[5]; }; Add the suitable code to the class Student to make the following code possible. void main() { Student s1, s2, s3; s1++; /* the above statement will increment by 5 each of the elements of grads in object s1*/ cout<< (s3 >s1); /* the above statement will print 1 if the average all elements of grades in s3 is higher than the average elements of grads in object s1, otherwise the statement will print 0 */ If (s1==s2) cout<< same ; /* the above statement will print 1 if s1 is equal to s2, and will print 0 otherwise */ }

Question 5 Define function LocateElement that will take two inputs: an integer x and an array of integer numbers. The function then will return the following outputs: The index (or position) of the first element in the array that has the same value as x. The count of all elements in the array that have value equal to x. The address of last element in the array that has the same value as x. Note: Never use cin or cout in the function

Question 6 Assume the following class is defined. The class name is Car and has two private attributes: ID which is an integer and type which is a string (examples of model "escotta", "corrolla". The class has the following access methods: SetID, Settype, GetID, GetType. The class doesn't have a default constructor; instead it has a constructor that takes two parameters to initializes ID and type. Don't define the Car class or any of the mentioned methods. Define the class copy constructor for the Car class. Define class Employee which has the following private attributes: EmpID as integer, EmpName as string, and EmpCar as object of Car. Implement the class constructor that will receive three parameters to initialize all attributes. Define method print for this class that will print out all the values of all attributes of an Employee object. Note: This Employee class should never have default constructor. Write necessary statements in main function that will define obj1 as an object of Employee class.