Interview questions Flashcards

1
Q

What is encapsulation ?

A

Encapsulation in Java is a process of wrapping code and data together into a single unit.

Example: Creating a fully encapsulated class in Java by making all the data members of the class private. Now we can use setter and getter methods to set and get the data in it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you select all tables and rows in SQL, what query?

A

SELECT * FROM table_name

Explanation:

using “*” after “SELECT” fetches all the fields available from the identified table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between == and ===?

A

== in JavaScript is used for comparing two variables, but it ignores the datatype of variable. === is used for comparing two variables, but this operator also checks datatype and compares two values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is polymorphism? Explain and give an example.

A

Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.

Any Java object that can pass more than one IS-A test is considered to be polymorphic. In Java, all Java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is abstraction? Explain and give an example.

A

Abstraction is a process of hiding the implementation details and showing only functionality to the user.

Another way, it shows only essential things to the user and hides the internal details, for example, sending SMS where you type the text and send the message. You don’t know the internal processing about the message delivery.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the relationship between a class and an object?

A
class:
a class describes the contents of the objects that belong to it: it describes an aggregate of data fields (called instance variables), and defines the operations (called methods).
object:
an object is an element (or instance) of a class; objects have the behaviors of their class. The object is the actual component of programs, while the class specifies how instances are created and how they behave.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a string? Explain and give an example.

A

A string is a data type, such as an integer and floating point unit, but is used to represent text rather than numbers.

For example, the word “orange” and the phrase “The sky is blue” are both strings. … Even “12345” could be considered a string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is inheritance? Explain and give an example.

A

Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object.

class Employee{  
 float salary=40000;  
}  
class Programmer extends Employee{  
 int bonus=10000;  
}  
}
Programmer is the subclass and Employee is the superclass. The relationship between the two classes is Programmer IS-A Employee. It means that Programmer is a type of Employee and therefore Programmer inherits   all the properties and behaviors of a parent object.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between an array and an array list?

A

Array is a fixed length data structure whereas ArrayList is a variable length Collection class. We cannot change length of array once created in Java but ArrayList can be changed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is HTML and provide a list of tags?

A

Hyper text markup language

some tags: p, a, ul, ol, head, body, header, footer, strong, u, em

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you declare a variable in JavaScript?

A

You declare a JavaScript variable with the var keyword: var varName and after the declaration, the variable has no value (technically it has the value of undefined ). An equal sign is used to assign values to variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the purpose of CSS?

A

CSS describes how HTML elements are to be displayed on screen, paper, or in other media

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a loop? List them.

A

A loop statement allows us to execute a statement or group of statements multiple times.

Loops:
for
while
do..while

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a conditional statement?

A

An expression that only executes if the given condition is true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a do-while loop?

A

The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the four pillars of OOP?

A

Inheritance
Polymorphism
Encapsulation
Abstraction

17
Q

What is a while loop?

A

Java while loop is a statement that allows code to be executed repeatedly based on a given true/false condition. The while loop can be thought of as a repeating ‘if’ statement.