Tutor profile: Arif A.
Subject: Python Programming
Why should we use list comprehensions ?
List comprehensions are often thought of as a "Pythonic" way to implement creating a new list from previous data. The other alternative is to use append operation to add elements to the list one at a time. This is much slower than using list comprehension because during run-time a pointer has to move to the end of the list every time and only then can it add the element at the end.
Subject: Java Programming
How are interfaces in Java important from the perspective of code design ?
If a class can be thought of as a blueprint for an object, then we can think of interfaces as being blueprints for classes. Interfaces lay down a basic skeleton which every inheriting class must adhere to. An inheriting class must implement the bare minimum of methods whose function definitions are present in the interface. It enforces good code design by classifying together otherwise unrelated classes. Also, it makes sure that any class implementing the interface will implement at least a basic level of functionality.
Subject: C++ Programming
What is a major difference between template programming in C++ and generics in Java ?
A major immediate difference when writing Java generics code is that they do not allow the use of primitive datatypes but only classes. This means that during compilation, a template in C++ provides complete type-safety, because any two datatypes are compiled to their own separate classes for a similar template. Hence, the generated byte-code becomes filled with many separate instances of template implementations. One for each type in the main code. A Java Generic provides type-safety, and since all classes inherit from "Object" type, the byte-code contains just one implementation. Hence, the byte-code does not get too large.
needs and Arif will reply soon.