OOP SEM-IN EXAM KEY.pdf - Odd Semester 2018-19 Sem-In...

This preview shows page 1 - 3 out of 9 pages.

Odd Semester, 2018-19 Sem-In Examinations-I, Sep 2018 B. Tech. (CSE,ECM,BT), 2017 Batch II/IV, 1st Semester 17CS2004: Object Oriented Programming KEY Max. Marks: 50 Scheme of Evaluation: Basically programs are logic oriented; verify whether concept to be used in the given question is followed by the student or not. When concept asked is not satisfied, minimum marks can be given for syntax and logic etc. If everything is correct give full marks Part-A (5 X 4M=20M) 1. Explain the principles of OOP. OOP Principals 1) Inheritance 2) Polymorphisum 3) Abstraction 4) Encapsulation Inheritance: 1M The process of getting properties and behaviors from one class to another class is called inheritance. The main purpose of the inheritance is code extensibility whenever we are extending automatically the code is reused. In inheritance one class giving the properties and behavior and another class is taking the properties and behavior. By using extends keyword we are achieving inheritance concept. In the inheritance the person who is giving the properties is called parent the person who is taking the properties is called child. Polymorphism: 1M One thing can exhibits more than one form called polymorphism. The ability to appear in more forms. Polymorphism is a Greek word poly means many and morphism means forms. Two types of polymorphism: a. Compile Time Polymorphism (Early binding/Static binding) Ex:-Method Overloading b. Run Time Polymorphism (Late binding/Dynamic binding) Ex:-Method Overriding Abstraction:- 1M Hiding the internal implementation and highlighting the set of services that process is called abstraction. Encapsulation:- 1M The process of binding the data and code as a single unit is called encapsulation. We are able to provide more encapsulation by taking the private data (variables) members. 2. Discuss the usage of this keyword, and demonstrate with a program This is a Keyword that refers to the object of the class where it is used. In other words, ’this’ refers to the object of the present class. Generally, we write instance variables, constructors and methods in a class. All these members are referenced by ‘this’. So this can be referring to all the thing s of the
Image of page 1

Subscribe to view the full document.

present object. 2M import java . io .*; class Sample { int x ; Sample () { this ( 55 ); this . acess (); } Sample ( int x ) { this . x = x ; } void access () { System . out . println ( “x = + x ); } } class ThisDemo { public static void main ( String args []) { Sample s = new Sample (); } } 2M 3. Develop a java program to demonstrate static variable, static method. class StaticExample 4M { static int a = 10 ; static int b ; static void mystaticMethod ( int x ) { System . out . println ( "x = " + x ); System . out . println ( "a = " + a ); System . out . println ( "b = " + b ); } } class MyStaticDemo { public static void main ( String args []) { StaticExample . mystaticMethod ( 100 ); } } 4.
Image of page 2
Image of page 3

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern