Singly linked list implementation

Singly Linked Lists are a type of data structure. It is a type of list. In a singly linked list each node in the list stores the contents of the node and a pointer or reference to the next node in the list. It does not store any pointer

Read More

What is the difference between an interface and abstract class?

The key technical differences between an abstract class and an interface are:

  • Abstract classes can have constants, members, method stubs (methods without a body) and defined methods, whereas interfaces can only have constants and methods stubs.
  • Methods and members of an abstract class can be defined with any visibility, whereas all methods of an interface must be defined as public (they are defined

    Read More

Why are interface variables static and final by default?

Interface variables are static because Java interfaces cannot be instantiated in their own right; the value of the variable must be assigned in a static context in which no instance exists. The final modifier ensures the value assigned to the interface variable is a true constant that cannot be re-assigned

Read More

Diamond Problem ?

Due to diamond problem java doesn’t support multiple inheritance.


Multiple inheritance is not supported by Java using classes , handling the complexity that causes due to multiple inheritance is very complex. It creates problem during various operations like casting, constructor chaining etc and the above all reason is that there

Read More

Association, Composition and Aggregation in Java

Association

Association is relation between two separate classes which establishes through their Objects. Association can be one-to-one, one-to-many, many-to-one, many-to-many.
In Object-Oriented programming, an Object communicates to other Object to use functionality and services provided by that object. Composition and Aggregation are the two forms of association.


Output:

In above example

Read More

Doubly linked list implementation

A doubly-linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains two fields, called links, that are references to the previous and to the next node in the sequence of nodes. The beginning and ending nodes previous and

Read More

What is difference between concrete classes and abstract classes?

Abstract classes usually have partial or no implementation. On the other hand, concrete classes always have full implementation of its behavior.Unlike concrete classes, abstract classes cannot be instantiated. Therefore abstract classes have to be extended in order to make them useful. Abstract classes may contain abstract methods, but concrete classes

Read More

Define public, static, final ?

public: for the accessibility across all the classes, just like the methods present in the interface

static: as interface cannot have an object, the interfaceName.variableName can be used to reference it or directly the variableName in the class implementing it.

final: to make them constants. If 2 classes implement the same interface

Read More

Difference between association and dependency?

Association –> has-a C object (as a member variable)

Dependency –> references B (as a method parameter or return type)

 

Dependency – A change in a class affects the change in it’s dependent class. Example- Circle is dependent on Shape (an interface). If you change Shape , it affects Circle too. So, Circle has a dependency on Shape.

Association– means

Read More

What are Object Oriented Programming (OOPs) Concept ?

  • Abstraction
  • Encapsulation
  • Polymorphism
  • Inheritance
  • Association
  • Aggregation
  • Composition

Abstraction

Abstraction is the concept of hiding the internal details and describing things in simple terms. For example, a method that adds two integers. The internal processing of the method is hidden from the outer world. There are many ways to achieve abstraction in object-oriented programmings, such as encapsulation

Read More