Académique Documents
Professionnel Documents
Culture Documents
1
}
6. What is a template?
Templates are the foundation of generic programming, which involves writing
code in a way that is independent of any particular type.
A template is a blueprint or formula for creating a generic class or a function. The
library containers like iterators and algorithms are examples of generic
programming and have been developed using template concept.
There is a single definition of each container, such as vector, but we can define
many different kinds of vectors for example, vector <int> or vector <string>.
2
behaviors defined by its class. A class can contain fields and methods to describe the
behavior of an object.
An interface is a reference type in Java. It is similar to class. It is a collection of
abstract methods. A class implements an interface, thereby inheriting the abstract
methods of the interface. Along with abstract methods, an interface may also contain
constants, default methods, static methods, and nested types.
3
16. What are the life cycles of thread?
New born state
Runnable state
Running state
Blocked state
Dead state