3i Infotech Papers: Sample Questions 969 - 970 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 969

» Languages » Java

Appeared in Year: 2004

MCQ▾

Question

If this method is overridden in a sub class, ________

Choices

Choice (4) Response

a.

The return type of new method should exactly match that of overridden method

b.

The new method can return any type of values

c.

The argument list of new method should exactly match that of overridden method

d.

Both c. and a. are correct

Answer

d.

Explanation

  • The overriding method has the same name, number and type of arguments, and return value as the method it overrides. (return type of a subclass can be a subclass of the return type of its superclass).

  • Overriding method can have different throws clause if it doesn’t specify any types not specified by the throws clause in the overridden method.

  • The access specifier for the overriding method can allow more but not less access than the overridden method. For example, a protected method in the superclass can be made public but not private.

Question number: 970

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

What is abstraction?

Explanation

Understanding of data abstract

Understanding of Data Abstract

Understanding of data abstract

  • Data abstraction is key concept in object-oriented programming in C++.

  • Abstraction displays only the essential information and hiding the (implementation) details.

  • Abstraction provides the interface to the user without bothering him about the implementation. For example when using the mobile phone user only interacts with the screen elements without being concerned about phone’s innards.

Abstraction using classes:

  • We implement abstraction in C++ using classes.

  • Classes group data members and member functions using available access specifiers.

  • Class implementer decides which data member will be visible to outside world.

Abstraction in header files:

  • One more abstraction in C++ is header files.

  • For example consider the pow () method present in math. h header file.

  • We call the function pow () present in the math. h header file and pass the number argument without worrying about the implementation.