In: Computer Science
1.) Many languages (e.g., C and Java) distinguish the character ’c’ from the string “c” with separate sets of quotation marks. Others (e.g., Python) use “c” for both single characters and strings of length one. Provide (and justify) one advantage and one disadvantage of Python’s approach.
2.The designers of Java distinguish the primitive types (scalars) from the reference types (all other types of values) in the language. Discuss the costs and benefits to the programmer of this decision
3.In Ruby, the Hash class accepts the “each” method, allowing hashes to be interacted over, like a collection. In Java, however, the Map classes are not formally part of the JCF (Java Collections Framework). For both Ruby and Java, provide (and justify) an advantage of the language’s choice of location in the class hierarchy of its form of associative list
4.What are the basic differences, if any, in how Java and Ruby handle information hiding (a.k.a. encapsulation)?
5. Java and C++ support generic collections with type parameters, whereas Ruby does not. Does that fact place the Ruby programmer at a disadvantage? Why or why not?
Multiple questions posted, first two questions are answered below, please comment if any doubts:
1.
Advantage of using double quotes for character and single character string python:
Disadvantage of using double quotes for character and single character string python:
2.
By distinguishing primitive types from reference types the cost of the program can be reduced in terms of memory usage and execution time. The primitive types used very less memory compared to reference types. Thus this distinguish ion will make the use of low memory usage primitive scalars whenever it is required by replacing reference types for all the usages. Thus the programmer will get the enhanced depth in the usage of data types in the program. The complexity of the program can be reduced and also the object oriented approach can be improved.