Shriansh Kumar

Shriansh Kumar

211 Articles Published

Articles by Shriansh Kumar

Page 7 of 22

Java Runtime Polymorphism with Multilevel Inheritance

Shriansh Kumar
Shriansh Kumar
Updated on 17-Apr-2025 3K+ Views

In Java, multilevel inheritance allows a class to inherit attributes and methods from another class by creating a multiple layer of inheritance. Runtime polymorphism lets a child class to provide different implementations of inherited methods through method overriding. When we implement runtime polymorphism using multilevel inheritance, call to the overridden method is decided at the run time by JVM on the basis of object type. In this article, we are going to demonstrate runtime polymorphism in Java using multilevel inheritance. But, let's discuss runtime polymorphism first. What is Runtime Polymorphism in Java? Runtime polymorphism is a type of polymorphism ...

Read More

Nested Interface in Java

Shriansh Kumar
Shriansh Kumar
Updated on 17-Apr-2025 4K+ Views

In Java, an interface defined inside another interface or class is called nested interface. Interfaces are similar to classes, but they not contain instance variables, and their methods are declared without any body. You can specify what a class must do, but not how it does it using the interface keyword. In this article, we will learn about nested interfaces in Java. What is a Nested Interface in Java As mentioned earlier, we can declare an interface within another interface or class. Such an interface is termed as nested interface. It follows the same syntax as a regular interface ...

Read More

Can we overload or override a static method in Java?

Shriansh Kumar
Shriansh Kumar
Updated on 16-Apr-2025 5K+ Views

In Java, you cannot override static methods but you can overload them. Overloading a static method is allowed because the JVM determines which method to call at compile time based on the method signature, rather than the object's type. However, overriding is not allowed for static methods because an overridden method is called based on the object's type. In this article, we are going to discuss is it possible to overload and override a static method in Java. Also, we will understand static methods, method overloading and method overriding. What is a Static Method? A method defined using the static ...

Read More

Java program to compare two sets

Shriansh Kumar
Shriansh Kumar
Updated on 12-Apr-2025 2K+ Views

The given task is to write Java programs that compare two sets and check if they are equal or not. Here, Set is an interface of the Java Collection Framework that extends the Collection interface and stores unique elements. Set depicts the features of a mathematical set. Hence, it allows all those operations that we can perform on a mathematical set, such as union, comparison, intersection, etc. Since Set is an interface, we can't use its functionalities directly. For this purpose, we need a TreeSet class that implements the Set Interface and can access its methods. How to Compare Two Sets in ...

Read More

How to Create Your Own Annotations in Java?

Shriansh Kumar
Shriansh Kumar
Updated on 09-Apr-2025 1K+ Views

When we start learning Java, we often wonder about symbols like @override and @inherited. They are a special kind of tag termed as Annotations that can be applied to classes, methods, fields, parameters, and other elements of the code. Java provides support for some built-in annotations, however, we are allowed to create our own annotations too. In this article, we are going learn how to create and use our own custom annotations. Before creating our own annotations, let's familiarize ourselves with the basics of annotations in Java. What are Annotations? Annotations are features of Java that allows us to add ...

Read More

Difference Between VB.NET and Java

Shriansh Kumar
Shriansh Kumar
Updated on 09-Apr-2025 986 Views

VB.NET and Java are the two widely used programming languages available nowadays. They serve to develop a variety of software including web and android applications. The features and capabilities of both languages make it difficult to choose one over another. In this article, we will compare and analyze them based on some parameters such as syntax, features, performance, and applications to point out the difference between VB.NET and Java. VB.NET vs Java Before discussing the difference between both technologies, let's have a quick introduction about them. VB.NET It is an abbreviation that stands for Visual Basic .NET. It is ...

Read More

Is there a case when finally block does not execute in Java?

Shriansh Kumar
Shriansh Kumar
Updated on 09-Apr-2025 2K+ Views

Questions related to Java exception handling are very frequent in interviews for many companies and even in exams. One such question that an interviewer might ask is whether there is a case when the finally block does not execute in Java. We will try to find the answer to this question in the simplest way possible. In Java, the finally block is designed to execute regardless of whether an exception is thrown or handled in the try-catch blocks. However, finally block may not execute if System.exit() is called either inside try or catch block. Before moving to the question, ...

Read More

JavaScript Program for Left Rotation and Right Rotation of a String

Shriansh Kumar
Shriansh Kumar
Updated on 21-Jan-2025 1K+ Views

To implement left rotation and right rotation of a string, we can use various approaches to implement this problem. Left rotation of a string means anti-clockwise movement of the given number of characters and right rotation of the string means clockwise movement of the given number of characters. In this article we are having a string and a value of k by which we will rotate the string. Our task is to write a JavaScript program for left rotation and right rotation of a string. Example Input: String str = "apple"; k = 3 Output: Left Rotation: ...

Read More

JavaScript Program to Check if a Given Year is Leap Year

Shriansh Kumar
Shriansh Kumar
Updated on 17-Jan-2025 2K+ Views

To check if a given year is leap year, We have used two approaches in this article. A leap year has 366 days. In every 4th year, an additional day is added to the month of February to synchronize it with astronomical year. In this article, we are given with two years to check. Our task is to write a JavaScript program to check if a given year is leap year. Approaches to Check Leap Year Here is a list of approaches to check if a given year is leap year in Javascript which we will be discussing ...

Read More

Java Program for Reversal algorithm for right rotation of an array

Shriansh Kumar
Shriansh Kumar
Updated on 07-Jan-2025 395 Views

An array is a linear data structure that stores a group of elements with similar datatypes, in a sequential order. Once we create an array, we can’t change its size, i.e., it can store a fixed number of elements. In this article, we will learn how to write a Java program where we create an array and perform the right rotation using the reversal algorithm. Right Rotation of an Array Let’s understand the term right rotation in the context of an array. In the right rotation of an array, we simply shift the elements of the array to our right till the specified number ...

Read More
Showing 61–70 of 211 articles
« Prev 1 5 6 7 8 9 22 Next »
Advertisements