General Interview Topics

Puneet Kumar
3 min readJul 12, 2021

1. Abstraction:

Hiding the implementation details, showing only essential.

For Example, we don’t know what is in exe fires to download an API, but only install Interface, we can’t see method /package in exe files. When we download any software.

2. Encapsulation:

wrapping of code + data into a single entity.

a) Public

b) Private

c) Protected

3. Method Overloading:

Same Name, different parameter.

→ Parameter must be different

→ Compile time polymorphism.

→ Performed within class.

class Test
{
public void m1 (int t)
{
}
public void m1 (long l)
{
}
}

4. Method Overriding:

→ Parameter must be same.

→ Runtime polymorphism.

→ Performed between two classes which have inheritance relationship..

class P
public void property ()
{
console.writeline("Cash");
}
public void marry ()
{
console.writeline("Hi");
}
class C extends P
public void marry ()
{
console.writeline("PuneetShivaay");
}

5. Range():

→ represent a sequence of values

→ immutable

→ valid on integer range, not float.

>>> range (10)

It represent values 0 to 9 (end-1)

6. Inheritance:

Inheritance is a mechanism in which one class acquires the property of another class.

For example, a child inherits the traits of his/her parents. With inheritance, we can reuse the fields and methods of the existing class.

a) single

b) multiple

c) multilevel

7. Polymorphism:

The word polymorphism means having many forms. …

Real life example of polymorphism: A person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee. So the same person posses different behavior in different situations. This is called polymorphism.

→ Performing same task in different ways

→ completely deals with method.

→ same method in different ways.

add (x,y) → different example.
add () → different example.
'+' → Arithmetic addition ( for integers)'+' concatenation (for string)

8. Difference between List & Tuple:

The main difference between lists and tuples is the fact that lists are mutable whereas tuples are immutable.

A mutable data type means that a python object of this type can be modified.

An immutable object can’t.

Let’s create a list and assign it to a variable.

>>> a = ["apples", "bananas", "oranges"]

Now let’s see what happens when we try to modify the first item of the list.

Let’s change “apples” to “berries”.

>>> a[0] = "berries"
>>> a
['berries', 'bananas', 'oranges']

Perfect! the first item of a has changed.

Now, what if we want to try the same thing with a tuple instead of a list? Let’s see.

>>> a = ("apples", "bananas", "oranges")
>>> a[0] = "berries"
Traceback (most recent call last):
File "", line 1, in
TypeError: 'tuple' object does not support item assignment

We get an error saying that a tuple object doesn’t support item assignment.

The reason we get this error is because tuple objects, unlike lists, are immutable which means you can’t modify a tuple object after it’s created.

9. Tuple Data type:

() parenthesis convention

Tuple is immutable and all is same.

>>> t= (10, 20, 30)
>>> t[0] =100
TypeError: 'tuple' object does not support item assignment
>>> t= (10, 20, [2,6])
it is valid

--

--