0% found this document useful (0 votes)
6 views

Lecture_7_Abstract_Data_Type_A

Uploaded by

a7medfaisal7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lecture_7_Abstract_Data_Type_A

Uploaded by

a7medfaisal7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lecture 7: Abstract Data Type - Questions and Answers

Student: Ahmed Faisal Ahmed Mohammed

Department: Computer Science

Year: Fourth

1. What is an abstraction?

Answer: Abstraction is the process of hiding the complex details of a system while exposing only the

essential and relevant features. Its goal is to simplify interactions and make systems more

manageable.

2. Define object?

Answer: An object is an instance of a class that encapsulates data (attributes) and behaviors

(methods). It is the fundamental unit in object-oriented programming (OOP).

3. What is a Java package, and what is its purpose?

Answer: A Java package is a namespace that organizes classes and interfaces into logical groups.

Its purpose is to prevent name conflicts and make code easier to locate, use, and manage.

4. Name two accessor methods that allow indirect access to hidden data.

Answer: The two common accessor methods are:

- get methods to retrieve data values.

- set methods to modify data values.

5. What are the languages that support abstract data types?

Answer: Languages that support abstract data types include:

- Java

- C++

- Python
- C#

- Ada

6. What is the use of a C++ destructor?

Answer: A destructor in C++ is used to release resources such as memory or file handles that were

allocated to the object when it goes out of scope.

7. How are instances of C++ template classes created?

Answer: Instances of C++ template classes are created by specifying the type to be used with the

template when declaring the object, such as TemplateClass<int>.

8. Describe the two problems that appear in the construction of large programs that led to

the development of encapsulation constructs.

Answer: The two key problems are:

- Managing complexity due to multiple components interacting.

- Ensuring data integrity by controlling access and protecting it from unintended interference.

9. What is the advantage of using a C++ namespace?

Answer: The primary advantage of using a namespace in C++ is to avoid naming conflicts between

classes or functions, especially when using multiple libraries in the same program.

10. What is the similarity between the class instances of Java and those of C#?

Answer: The similarity between class instances in Java and C# includes:

- Both are created dynamically on the heap.

- Both support inheritance and polymorphism.

- Both use constructors for initializing objects.

You might also like