Skip to main content

Posts

Showing posts from June, 2019

Difference between abstract class and interface in OOP

Source: Amit Sethi In Interface: > All variables must be public static final. > No constructors. An interface can not be instantiated using the new operator.   > All methods must be public abstract .  

Asynchronous vs Synchronous execution, what does it really mean?

Image source: youtube When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes. In Synchronous program execution, your program is executed line by line, one line at a time. Each time a function is called, program execution waits until that function returns before continuing to the next line of code. In solving many engineering problems, the software is designed to split up the overall problem into multiple individual tasks and then execute them asynchronously. For example, In computing, sorting a list is an example. The quicksort routine, for example, splits the list into two lists and sorts each of them by calling itself recursively. Real life example: SYNCHRONOUS You are in a queue to get a movie ticket. You cannot get one until everybody in front of you gets one, and the same applies to the people queued behind you. ASYNCHRONOUS ...

OOP concepts in Java

What is the Class?  The class is a group of similar entities. It is extensible program code for creating objects and to define data types as well as methods. What is Object in OOP? Object refers to a particular instance of a class whereas objects can be a combination of variables, functions and data structures. What are the 4 principles in OOP? Encapsulation, Data Abstraction, Polymorphism and Inheritance. What is Inheritance? Deriving a new class from an existing class and forming them into a hierarchy of classes. What is Encapsulation?   It is used to hiding the implementation details. What is Constructor overloadin?  It is a feature that allows a class to have more than one constructor having different argument lists. What is the difference between method overloading vs method overriding? Why do we need to use Method Overloading? Suppose that you have a class that can use calligraphy to draw various types of data (strings, in...