AMCAT coupon code --> AF01 (Upto 150 off)

AMCAT Encapsulation Questions with Solutions 2019 – Computer Programming

AMCAT Encapsulation Questions in Computer programming section: First of all, AMCAT exam is one of the most sought after employment tests. Especially for Engineering candidates, apart from Quantitative and Reasoning abilities and English language, Computer Programming is a mandatory module in the test. In addition, this section aids as a befitting factor to the IT job aspirants. Get to know in detail about AMCAT Encapsulation Questions with their solutions as per the latest pattern.

AMCAT Encapsulation Questions with Solutions- Computer Programming 2019

AMCAT Encapsulation Questions

The syllabus of Computer programming includes Basic programming, Object Oriented Programming (OOP)language, Data structures and miscellaneous questions also. Under OOP, comes the topic of Encapsulation.
As much as, 2-3 problems come from this topic. The level of the questions is rather average. Furthermore, here you will get complete information on encapsulation basic concepts and relevant sample questions related to it.

Download Company Wise Placement Papers

Overview of Encapsulation in OOP 2019

Encapsulation is an Object Oriented Programming concept that rather binds a group of related properties, functions, and other members into a single unit. Consequently, Class is the best example of Data Encapsulation. It is also called data hiding that prevents the user to access the implementation details. Encapsulation therefore guarantees the integrity of the data contained in the Object.
It will be more clear, especially from the below example:

public class Student
  private string studentName; //Retrieve name
  public string Getname()
     return studentName;
  } // Set name
  public void Setname(string inName)
   studentName = inName;
public static void Main()
   string sName =”Jack”;
   Student obj = new Student();
   System.Console.WriteLine(“Name :” + obj.Getname());

In the above example, while, Getname() and Setname() methods have been used to retrieve and set student name. Also, variable studentName has been declared as private in class student. Since it is not accessible directly by the user, therefore, we use the Getname() and Setname() methods respectively. Hence, a user cannot get to know how implementation takes place. So, we can see that data encapsulation is achieved through the state (the private fields) and the behaviors (the public methods) of the object. In this way, the private data members of one class, are rather inaccessible by others and their implementation is hidden for outside classes. As a result, data encapsulation is known as data hiding.

Access Modifiers

Data Encapsulation is rather implemented by using access specifiers (Access Modifiers) and it defines the scope and visibility of a class member.

In C++, a class can contain private, protected and public members. Also, by default all items defined in a class are private. In conclusion, following is the scope of the access specifiers.

  • Private members especially, cannot be used outside of the class and by default, all members are private in a class.
  • Protected data members can be used rather within the parent class. Yet, the child class that inherits the parent class can use its attributes as well as methods too.
  • However, Public members can be accessed by any other class in the code.

Download AMCAT Encapsulation Questions

AMCAT Encapsulation Important Questions pdf with Solution

Sample Questions for AMCAT Encapsulation

Question 1
Which of the following statements is correct when a class is inherited publicly?
A. Public members of the base class become protected members of derived class.
B. Public members of the base class become private members of derived class.
C. Since Private members of the base class become protected members of derived class.
D. Public members of the base class become public members of derived class.
Answer: Option D

Question 2
Which of the following statements about virtual base classes is correct?
A. It provides multiple inheritance.
B. It is used to avoid multiple copies of base class in derived class.
C. It is used to allow multiple copies of base class in a derived class.
D. It allows private members of the base class to be inherited in the derived class.
Answer: Option B

Question 3
Encapsulation is?
A. Binds together code and data
B. Seems like Using single interface for general class of actions.
C. Reduce Complexity
D. All above
Answer: Option A

AMCAT Encapsulation Questions

Question 4
Which of the following concepts means wrapping up of data and functions together?
A. Abstraction
B. Encapsulation
C. Inheritance
D. None
Answer: Option B

Question 5
Which of the following are available especially only in the class hierarchy chain?
A. Public data members
B. Private data members
C. Protected data members
D. Member functions
Answer: Option C

Question 6
Palak enters a coding competition. She wants to write code to pass down values from one class to another?
A. Inherits
B. extends
C. Construct
D. all of the mentioned
Answer: Option B

Question 7
How will a class protect the code inside it?
A.  Using Access  specifiers.
B. Abstraction
C. Use of Inheritance
D. All of the mentioned
Answer: Option A

Question 8
Which of the following concepts means wrapping up of data and functions together?
A. Abstraction
B. Encapsulation
C. Inheritance
D. Polymorphism
Answer: Option B

More Articles AMCAT CSE Questions Paper:

Hope AMCAT Encapsulation Questions with Solutions is helpful to you.

Leave a Comment