Professional Documents
Culture Documents
ENGINEERING COLLEGE
RSM NAGAR, KAVARAIPETTAI 601 206
KEY
Sub. Title Sub. Code Time : Object Oriented Programming : CS2311 : 180 mins Date : Branch : EEE Max.Marks : 100
5.
6.
7.
8.
9.
(iv) Give a sample output. Class Rational { Int num,deno; // a/b Rational (int n, int d) { Num=n;deno=d; } Rational operator+(Rational r) { //add rational numbers and return object } Rational operator-(Rational r) { //add rational numbers and return object } } Main() { Rational r1 (1/2) ------R3=r1+r2 }
(8)
13. (a) Write a C++ program to demonstrate file handling as follows: get strings as input from the user, store them in a file, retrieve them and display them. (16) Steps: <create a text file> Get the string from user using getline() Open file in read mode Write string to file Close the file Open the file again in write mode Read the data and display it. Close the file Or (b) Explain the exception handling mechanism available in C++ with suitable examples (16) Define Exception (2) Syntax (4) Try{ } Catch() { } (10)
Program
14. (a) Write a java program to create two single dimensional arrays, initialize them and add them; store the result in another array (16) Int a[]=new int a[5] { 1,2,3,4,5} Int b[]=new int b[5]{1,2,4,5,6} For(; ; ;) { C[i]=a[i]+b[i]; } Or (b) (i) Describe the structure of a typical Java program and give the steps to execute it. (8) Structure of java program (4) Different sections in java program Steps to execute program (4) (ii) Explain with example how packages are created. Definition (2) Steps (2) Example (4) 15.(i) Describe the single inheritance with an example Java program (8) Definition (2) Syntax (1) Class subclass extends superclass { } Program (5) (ii) Describe the concept of interface with the syntax. Definition (2) Concept/properties (2) Example (4) Or (b) Explain the following with example (i) Streams and IO (6) Definition of streams (2) Types of streams (2) byte and char streams Explanation about stream classes(2) (ii) Threads concept (10) Definition and example (2) States (2) New, runnable, blocked, wating, timed waiting,terminated Program (6)
(8)