TCS Technical Interview Questions
1) Explain the functionality of the linked list.
A linked list consists of two parts: information and the link. In the single connected listening, the beginning of the list is marked by a unique pointer named to start. This pointer does point to the first element of the list and the linked part of each node consists of an arrow looking to the next node, but the last node of the list has a null pointer identifying the previous node. With the help of the start pointer, the linked list can be traversed easily.
2) What are the four basic principles of OOPS?
The four basic principles of Object-Oriented Programming System are listed below:
- Abstraction: Abstraction is a process of hiding the implementation details and showing only functionality to the user. For example, sending SMS where you type the text and send the message. You don't know the internal processing about the message delivery.
- Abstraction lets you focus on what the object does instead of how it does it.
- Inheritance: Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object.
- Encapsulation: Encapsulation in Java is a process of wrapping code and data together into a single unit, for example, a capsule that is mixed with several medicines.
- Polymorphism: Polymorphism in Java is a concept by which we can perform a single action in different ways. Polymorphism is derived from 2 greek words: poly and morphs. The word "poly" means many and "morphs" means forms. So polymorphism means many forms.
3) What is inheritance?
In, Object-Oriented Programming, inheritance is a mechanism based on classes.
Inheritance refers to inhering the data members and properties of a parent class to a child class. A class that is derived from another level is often called a sub-class or a child class, and the type from which the child class is obtained is known as super-class or parent class.
4) What is the way of inheriting the variable of one class to any other class?
//Base Class class A { public int a; } //Derived Class class B : A { a=15; }