Name : Fandy Limardi
NIM : 1601210713
Lecture : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment : Concept of programming languages ---- Chapter 11 Abstract Data Types and Encapsulation Constructs
Review Questions
2. Define abstract data types
·
the
representation of objects of the type is hidden from the program units that use
the
type
·
the
declarations of the type and the protocols of the operations on objects of the
type
3. What are the advantages of the two parts of
the definition of abstract data type
·
the
program will increase reliability, reduce the range of code and number
variables
·
it
provides a method of organizing a program into logical units that can be
compiled
separately.
5. What are the language design issues for
abstract data types
·
the
form of the container for the interface to the type
·
whether
abstract data type can be parameterized
·
what
access controls are provided and how such controls are specified
·
whether
the specification of the type is physically separate from its implementation
8. What is the difference between private and
limited private types in Ada?
·
Private
types in Ada, it has built-in operations for assignment and comparisons for
equality and inequality.
·
Limited
private types in Ada, are described in the private section of a package
specification,
as are non pointer private types. Limited private types are declared to be
limited private in the visible part of
the package specification.
9. What is in an ada package specification? What
about a body package?
A package specification and its
associated body package share the same name. The reserved word body in a
package header identifies it as being a body package. A package specification
and its body package may be compiled separately.
12. What is the fundamental difference between a
C++ class and an Ada package?
C++ classes are types ; as stated
previously, Ada packages are more generalized encapsulations that can define
any number of types. Ada packages can access any of its public entities
directly by their names. a C++ program unit that declares an instance of a
class can also access all of the public entities in that class, but only
through an instance of the class.
13. From where are C++ objects allocated?
from heap memory are C++ objects allocated
15. What is the purpose of a C++ destructor?
Destructor is often used as a
debugging aid, in which case they simply display or print the values of some or
all of the object's data members before those member are deallocated.
22. What is the use of @private and @public
directives?
the use of @private and @public
directives are to specify the access levels of the instance variables in a
class definition.
27. Where are all java methods defined?
All java methods are defined
completely in a class. A method body must appear with its corresponding method
header
28. Where are java classes allocated?
Java
classes allocated from the heap and accessed through reference variables.
45. Describe a .NET assembly
.NET assembly is a .NET
application that appears to be a single dynamic link library (.dll) or an
executable (.exe). An assembly defines a module, which can be separately
developed and includes several different components.
Problem Set
4. What are the advantages of
the nonpointer concept in Java?
·
There
is no memory leak such as dangling pointers or unnamed variables.
·
Memory
access via pointer arithmetic - this is fundamentally unsafe. Java has a
robust security model and disallows pointer arithmetic for this reason.
·
Array
access via pointer offsets – Java does this via indexed array access so you
don’t need pointers. A big advantage of Java’s indexed array access is that it
detects and disallows out of bounds array access, which can be a major source
of bugs.
·
References
to objects – Java has this, it just doesn’t call them pointers. Any normal
object reference works as one of these.
8. What
are the drawbacks of user-defined generic classes in Java 5.0?
Some drawbacks of user-defined generic classes in Java
5.0 are: for one thing, they cannot store primitives. Second, the elements
cannot be indexed. Elements must be added to user-defined generic collections
with the add method.
9. What
happens if the constructor is absent in Java and C++?
It will be made automatically by the
built-up in.
12. How
are classes in Ruby made dynamic?
Classes in Ruby are dynamic in the sense that members
can be added at any time. This is done by simply including additional class
definitions that specify the new members.
15. Give
one capability that Java 5.0 provides which C# 2005 does not.
One capability that Java 5.0 provides that C# 2005 does not is wildcard classes.
One capability that Java 5.0 provides that C# 2005 does not is wildcard classes.
In Ruby, the require statement is used to
import a package or a module. For example, the extensions package/module is
imported as follows. require ‘extensions’. External files may be included in a
Ruby application by using load or require. For
example, to include the external file catalog.rb, add the
following require statement. require “catalog.rb”. The
difference between load and require is
that load includes the specified Ruby file every time the
method is executed and require includes the Ruby file only
once. In Java, the import statement is used to load a package.
For example, a Java package java.sql is
loaded as follows. import java.sql.*;
No comments:
Post a Comment