Shriansh Kumar has Published 324 Articles

Covariant return types in Java

Shriansh Kumar

Shriansh Kumar

Updated on 24-Apr-2025 18:32:02

10K+ Views

In Java, covariant return types allow an overriding method to return a subtype of the supertype. Here, the return type of the parent class is called the supertype, and the return type of the child class is known as the subtype, if and only if it is a subclass of the parent ... Read More

Downcasting in Java

Shriansh Kumar

Shriansh Kumar

Updated on 24-Apr-2025 18:22:54

426 Views

What is Downcasting? Typecasting an object of the parent class to an object of the child class is called Downcasting in Java. We need to tell the Java compiler to perform the conversion explicitly by creating an object of the child type using a reference of the parent type. It ... Read More

Interface enhancements in Java 8

Shriansh Kumar

Shriansh Kumar

Updated on 24-Apr-2025 18:20:41

616 Views

Before the release of Java version 8, the interface consists of only abstract methods and variables that defines the behavior that a class could implement. While adding a new method to an interface, it required change in all the implementing classes. It was not convenient for a large application. To ... Read More

How to compile & run a Java program using Command Prompt?

Shriansh Kumar

Shriansh Kumar

Updated on 24-Apr-2025 18:17:52

19K+ Views

Command prompt is a command line interface that accepts text-based inputs or commands and performs tasks based on those command. Nowadays, there are various integrated development environments (IDEs) that are available to compile, build, and run Java programs within their environment. However, we can also compile and run Java programs ... Read More

What are the differences between while loop and do-while loop in Java?

Shriansh Kumar

Shriansh Kumar

Updated on 24-Apr-2025 18:17:00

8K+ Views

In Java, the do-while and while loops are used to repeat a block of code multiple times based on a condition. These loops help us to avoid writing the same code again and again. Both loops are used when we don't know exactly how many times the loop should run. ... Read More

method overloading and type promotion in Java

Shriansh Kumar

Shriansh Kumar

Updated on 21-Apr-2025 16:02:36

1K+ Views

Method overloading helps to create multiple methods with the same name to perform similar operations in different ways ( using different types of parameters). Automatic Type promotion or conversion in Java is a process in which the compiler automatically promotes a small-sized data type to a larger-sized data type. It ... Read More

Java program to check if string is pangram

Shriansh Kumar

Shriansh Kumar

Updated on 18-Apr-2025 18:49:33

12K+ Views

The given task is to write a Java program to check whether a string is a pangram or not. A string is called a pangram if and only if it contains all the letters of the English alphabet, regardless of their case. Example Scenario:Let's understand the problem with an example - ... Read More

HAS-A relationship in Java

Shriansh Kumar

Shriansh Kumar

Updated on 18-Apr-2025 18:46:44

2K+ Views

Java is a programming language that follows the Object-Oriented Programming paradigm. One of the pillars of OOPs is Inheritance, where you can find a relationship between two classes as Parent and Child. This relationship allows these classes to reuse each other's attributes and methods. Java classes can relate to each ... Read More

Java Runtime Polymorphism with Multilevel Inheritance

Shriansh Kumar

Shriansh Kumar

Updated on 17-Apr-2025 18:52:38

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 ... Read More

Nested Interface in Java

Shriansh Kumar

Shriansh Kumar

Updated on 17-Apr-2025 18:51:56

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 ... Read More

Previous 1 ... 7 8 9 10 11 ... 33 Next
Advertisements