Mahesh Parahar has Published 276 Articles

Differences between abstract class and interface in Java

Mahesh Parahar

Mahesh Parahar

Updated on 08-Dec-2023 10:45:00

4K+ Views

In Java, abstraction is achieved using Abstract classes and interfaces. Both contains abstract methods which a child class or implementing class has to implement. Following are the important differences between abstract class and an interface. Sr. No. Key Abstract Class Interface 1 Supported Methods Abstract class can have both an abstract as well as concrete methods. Interface can ... Read More

Differences between abstract class and concrete class in Java

Mahesh Parahar

Mahesh Parahar

Updated on 08-Dec-2023 10:35:21

8K+ Views

In Java, abstraction is achieved using Abstract classes and interfaces. An abstract class contains abstract methods which a child class. Following are the important differences between abstract class and a concrete class. Sr. No. Key Abstract Class Concrete Class 1 Supported Methods Abstract class can have both an abstract as well as concrete methods. A concrete class can ... Read More

Difference between Constructors and Methods in Java

Mahesh Parahar

Mahesh Parahar

Updated on 08-Dec-2023 10:19:00

18K+ Views

Constructors are special methods used to initialize objects whereas methods are used to execute certain statements. Following are the important differences between Constructors and Methods. Sr. No. Key Constructors Methods 1 Purpose Constructor is used to create and initialize an Object. Method is used to execute certain statements. 2 Invocation A constructor is invoked implicitly by the System. A method is to ... Read More

Differences between Interface and class in Java

Mahesh Parahar

Mahesh Parahar

Updated on 07-Dec-2023 11:54:40

18K+ Views

Class A class is a blueprint from which individual objects are created. A class can contain any of the following variable types. Local Variables − Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed ... Read More

Differences between ArrayList and LinkedList in Java

Mahesh Parahar

Mahesh Parahar

Updated on 07-Dec-2023 10:15:10

22K+ Views

Both ArrayList and LinkedList are implementation of List interface in Java. Both classes are non-synchronized. But there are certain differences as well. Following are the important differences between ArrayList and LinkedList method. Sr. No. Key ArrayList LinkedList 1 Internal Implementation ArrayList internally uses a dynamic array to store its elements. LinkedList uses Doubly Linked List to store its elements. 2 Manipulation ArrayList ... Read More

Difference between String buffer and String builder in Java

Mahesh Parahar

Mahesh Parahar

Updated on 05-Dec-2023 10:02:00

11K+ Views

String buffer and StringBuilder both are mutable classes which can be used to do operation on string objects such as reverse of string, concating string and etc. We can modify string without creating a new object of the string. A string buffer is thread-safe whereas string builder is not thread-safe. Therefore, ... Read More

Difference between List and Set in Java

Mahesh Parahar

Mahesh Parahar

Updated on 05-Dec-2023 09:48:36

2K+ Views

List and Set both interface belongs to the Collection framework. Both interfaces extend the Collection interface. They both are used to store a collection of objects as a single unit. Before jdk1.2, we used to use Arrays, Vectors, and Hashtable for grouping objects as a single unit. Sr. No. Key List Set 1 Positional Access The list provides ... Read More

The Graph Coloring

Mahesh Parahar

Mahesh Parahar

Updated on 07-Nov-2023 05:08:44

34K+ Views

Graph coloring is the procedure of assignment of colors to each vertex of a graph G such that no adjacent vertices get same color. The objective is to minimize the number of colors while coloring a graph. The smallest number of colors required to color a graph G is called ... Read More

Degree of Vertex of a Graph

Mahesh Parahar

Mahesh Parahar

Updated on 03-Nov-2023 13:39:03

27K+ Views

It is the number of vertices adjacent to a vertex V. Notation − deg(V). In a simple graph with n number of vertices, the degree of any vertices is − deg(v) = n – 1 ∀ v ∈ G A vertex can form an edge with all other vertices except ... Read More

How do you add an element to a list in Java?

Mahesh Parahar

Mahesh Parahar

Updated on 31-Oct-2023 03:55:30

24K+ Views

We can use add() methods of List to add elements to the list.1. Use add() method without index.boolean add(E e)Appends the specified element to the end of this list (optional operation).Parameterse − Element to be appended to this list.ReturnsTrue (as specified by Collection.add(E)).ThrowsUnsupportedOperationException − If the add operation is not ... Read More

1 2 3 4 5 ... 28 Next
Advertisements