Review Questions :
1. What are the two kinds of abstractions in programming languages?
process abstraction and data abstraction
2. Define ADT
ADT is a data type that is hidden from the program units, and the
declaration of the type and the protocols, are contained in a single
syntactic unit
3. What are the advantages of the two parts of the definition of abstract data type?
Information hiding, improved readability, and easier to manage
5. What are the language design issues for ADT?
Form of the container for the interface to the type, whether ADT can be
parameterized, type of access controls, whether the specification of
the type is separate from its implementation
6. Explain how information hiding is provided in an Ada package
In Ada, the designer of an Ada package can choose to make the type
entirely visible to clients or provide only the interface information.
7. To what is the private part of an Ada package specification visible?
The private clause is visible to the compiler but not to the client program units.
8. What is the difference between private and limited private types in Ada?
Limited private type is a more restricted form of private types
10. What is the use of the Ada with clause?
The with clause makes the names defined in external packages visible
11. What is the use of the Ada use clause?
The use clause eliminates the need for explicit qualification of the references to the entities from the named packages.
12. What is the fundamental difference between a C++ Class and and Ada package?
C++ classes are types, Ada packages are more generalized encapsulations
that can define any number of types. A c++ program unit that declares an
instance of a class can access any of the public entities in that
class, but only through an instance of the class instead of Ada package,
in which a program unit that gains visibility can access public
entities by their names
13. From where are C++ object allocated?
In the function where an object is created
14. In what different places can the definition of a C++ member function appear?
In the class or only in its header
__________________________________________________________________________________________________________________________________________________________________________________
Problem Set Questions :
3. Write an analysis of the similarities of and differences between the access specifier of Java and C++
Answer :
C++ and Java use classes, however in Java, reliability gets prioritized
over flexibility, Java and C++ classes are very similar in the term of
using protected, public, and private. Each access specifier is the same
whether in C++ or Java, in C++ private can only be accessed inside the
class, protected is private but can be inherited to a child class, and
public is accessible from outside the class. Java however need to
specify everything in when we declare a variable, while in C+ we only
need to write protected or private only once. Method must be defined
inside of a class in Java, and all objects are allocated form the heap
and accessed through reference variables.
4. What are the advantages of the nonpointer concept in Java?
The nonpointer concept in Java basically means that pointer is no longer
included in Java. Pointer is a powerful but dangerous tool to use, A
dangling pointer can have an impact to the overall program reliability,
hence why java decided not to include pointers. The advantages is that
java program is basically more reliable, and not prone to error without
the existence of pointers.
9. What happens if the constructors are absent in Java and C++?
We cannot assign values that we want on the creation time of the object,
instead we have to make a separate function to assign values, and this
can take time.
11. Why is the destructor of C# is rarely used?
Because C# uses garbage collection for most of its heap objects.
15. Give one capability that Java 5.0 provides which C# 2005 does not.
Answer :
One capability that Java 5.0 provides that C# 2005 does not is wildcard classes
ReplyDeleteVery informative article.Thank you author for posting this kind of article .
http://www.wikitechy.com/view-article/what-is-access-control-specifier-in-cpp-with-example-and-expanation
Both are really good,
Cheers,
Venkat