OBJECT ORIENTED PROGRAMMING CIS 3100

A subclass constructor invokes a super class

This preview shows page 14 - 16 out of 54 pages.

A subclass constructor invokes a super class constructor by using the super keyword. The super keyword is subjected to certain conditions, • Super may bee used within a subclass constructor method • It should be the first statement of the sub class method. • It must match the order and type of the instance variables declared in the super class. 99. Define method overriding. (Nov/Dec 2011) Method overriding is a mechanism in which the sub class method overrides the base class method. If the same function name is present in both the base class and the sub class then the sub class method overrides the base class method. 100. What are final variables, methods and classes? (Nov/Dec 2011) In order to prevent the subclasses from overriding the members of a super class we can declare them as final using the keyword ‘final’. e.g, final int SIZE = 100; final void show () {……..} final class A {……} 101. What is the various visibility controls used in java? The various visibility controls used in java are, • Public access • Private access • Protected access • Private protected access • Friendly access 102. What are the rules of thumb? The rules of thumb are, • Use public if the field is to be visible everywhere. • Use protected if the field is to be visible everywhere in the current package and also subclasses in the other packages. • Use “default” if the field is to be visible everywhere in the current package only. • Use private protected if the field is to be visible only in sub classes, regardless of packages. • Use private if the field is not to be visible anywhere except in its own class. 103. What are the steps involved in creating an array? Creation of an array involves three steps, • Declare the array – two forms, type array-name []; type [] array-name; • Create memory locations array-name = new type [size]; • Put values into the memory locations array-name [subscript] = value; type array-name [] = { list of values};
Image of page 14

Subscribe to view the full document.

104. What is an interface? (April/May 2011) An interface is basically a kind of class. It contains abstract methods and final variable declarations. It does not specify any code to implement these methods and data fields contain only constants. It is used to implement multiple inheritance. 105. How do you implement an interface? (Nov/Dec 2011) An interface can be implemented as follows, class class-name implements interface-name { variable declaration; methods declaration; } 106. What are the steps involved in creating our own package? The steps involved in creating our own package are, • Declare the package at the beginning of the file. • Define the class and declare it as public. • Create a sub directory. • Store the listing • Compile the file 107. Define thread. (April/May 2011) A thread is similar to a program that has a single flow of control. It is a tiny program or module that runs in parallel with others.
Image of page 15
Image of page 16
You've reached the end of this preview.

{[ 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