Languages [TCS Placement]: Sample Questions 105 - 106 of 131

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 105

Question

MCQ▾

How many instances of an abstract class can be created?

Choices

Choice (4)

a.

0

b.

13

c.

1

d.

5

Answer

a.

Explanation

  • No, you cannot create an instance of an abstract class because it does not have complete implementation.
  • Abstract class functions as a base for subclasses- like a template, or an empty or partially empty structure. It has to be extended before using.
  • Abstract classes can have consts, members, method stubs and defined methods, whereas interfaces can only have consts and methods.

    abstract class MyAbstractClass

    {

    }

    MyAbstractClass obj = new MyAbstractClass () ; //not valid

  • Compiling the above code, generates the Error message: “Cannot create an instance of the abstract class or interface” .
Given the Image is Define the Abstract Class

Question 106

Question

MCQ▾

Which of the following operator is overloaded for object cout?

Choices

Choice (4)

a.

<<

b.

+

c.

=

d.

>>

Answer

a.

Explanation

  • We use insertion operator (<<) for the object (cout) of output stream.
  • So this is the operator that gets used. Hence the answer is << .
  • To send output to the screen we use the insertion operator on the object cout.
  • Format: cout << Expression;
Given the Image is Define the Insertion Operation Using in Cout Object

Developed by: