8. For each one of the following statements about Java, indicate whether or not
ID: 3789265 • Letter: 8
Question
8. For each one of the following statements about Java, indicate whether or not it is also true for Smalltalk. If a statement is not true for Smalltalk, explain why not.
(a) Java is normally implemented using a hybrid implementation system.
(b) Data in Java is divided into two categories: primitive types and reference types.
(c) Variables in Java must have a declared type.
(d) Java relies on garbage collection to reclaim memory occupied by objects that are no longer in use.
(e) Java’s classes are part of a single class hierarchy.
(f) Java supports only single inheritance, not multiple inheritance.
ANSWER in relation to SMALLTALK NOT JAVA ... if you answer in relation to JAVA I will report
Explanation / Answer
(a) SMALLTALK is normally implemented using a hybrid implementation system.
Due to the fact that DEC VAX/Smalltalk-80 was based on 32-bit words, the DEC implementation used 31-bit object names, using the 32nd bit as the SmallInteger tag. This enabled Smalltalk to use 31-bit long SmallIntegers, thereby eliminating the need for LargePositiveIntegers as indices to large arrays. The implementors also decided to use some kind of “virtual object” system, in order to allow for a very large number of objects. The designer’s goal was to use a hybrid system of object swapping and paging in order to get a low faulting rate and to have Smalltalk run on paged systems.
(b) Data in SMALLTALK is divided into two categories: primitive types and reference types.
In contrast to most popular object-oriented languages, which distinguish between native data types and class-based objects, everything in Smalltalk is an object. This is partly due to the fact that one of the Smalltalk paradigms is to write as much as possible in Smalltalk itself. Only parts that must be implemented in machine code (such as I/O primitives or basic arithmetic operations) are part of the virtual machine.
(c) Variables in SMALLTALK must have a declared type.
A new object is allocated by sending a new message to its class. To explicitly deallocate an object is not possible, because this could result in errors such as variables still referencing an object which no longer exists. Thus, the reference counting algorithm is used to ensure that objects that are no longer in use will be destroyed. so variables should be declared. In Smalltalk, variable names are used to refer to the object pointed to by the variable.
(d) SMALLTALK relies on garbage collection to reclaim memory occupied by objects that are no longer in use.
Every object has a counter that is incremented whenever a variable is assigned a pointer to that object. As soon as the variable is destroyed or reassigned another value, the reference counter is decremented. As soon as the counter reaches zero, the object can be destroyed. garbage collection is an area where the performance of the Smalltalk system can be improved significantly. This observation has been confirmed by "Richard Meyers and David Casseres" and "David M. Ungar and David A. Patterson"
(e) SMALLTALK’s classes are part of a single class hierarchy.
The Smalltalk class hierarchy
As we have seen, classes in Smalltalk are arranged in the form of a tree. The class above a given class in the hierarchy is its superclass; classes below are its subclasses. As in other object-oriented languages class inherits attributes from its superclasses.
These attributes include —
When each class has a single (immediate) superclass, the system is said to have simple inheritance. (Some languages support multiple inheritance.) The set of all messages that an object responds to is called its message protocol.
(f) SMALLTALK supports only single inheritance, not multiple inheritance.
Multiple inheritance is a generalization of standard inheritance that permits multiple superclasses. It is useful for creating new objects that share behavior common to several existing classes of objects. In Smalltalk, the facility is experimental since there are no examples using it A standard example where it might have been used would be to define a class of objects called ReadWriteStream by combining the behaviors of ReadStream and WriteStream. For example, this could be done by executing the following code:
class named: #ExperimentalReadWriteStream
superclasses: 'ReadStream WriteStream'
Instance variable names: ''
class variable names: "
category: 'Experimental'
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.