Languages [TCS Placement]: Sample Questions 52 - 53 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 52

Question

MCQ▾

Which of the following concepts means wrapping up of data and functions together?

Choices

Choice (4)

a.

Polymorphism

b.

Abstraction

c.

Inheritance

d.

Encapsulation

Answer

d.

Explanation

  • Encapsulation is wrapping up of data and functions together- class in C ++ is the wrapper.
  • Encapsulation thus encloses function and members within classes. Objects contain these attributes and the methods.
  • Data and functions thus form a single unit.
Given the Image is Define the Encapsulation

Question 53

Question

MCQ▾

Which of the following is an abstract data type?

Choices

Choice (4)

a.

double

b.

class

c.

int

d.

string

Answer

b.

Explanation

  • Class is an abstract data type.
  • Classes are the most important feature of C ++ that leads to Object Oriented programming.
  • Class is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating instance of that class.
  • Class name must start with an uppercase letter (although not mandatory) .
  • If class name is made of more than one word, then first letter of each word must be in uppercase. Example, class Study, class StudyTonight etc
  • Classes contain data members and member functions, and the access of these data members and variable depends on the access specifiers (discussed in next section) .
  • Classes in c ++ are similar to structure in c- but class defaults to private access control, whereas structure defaults to public.
Given the Image is Define the Class in C ++

Developed by: