Create Your Own Annotations in Java

Shriansh Kumar
Updated on 09-Apr-2025 19:35:54

675 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
Updated on 09-Apr-2025 19:34:30

600 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

Parameterized Constructor in Abstract Class in Java

Alshifa Hasnain
Updated on 09-Apr-2025 19:33:58

4K+ Views

A common question in Java OOPs is whether abstract classes can have parameterized constructors. Yes, we can define a parameterized constructor in an abstract class. What is a Parameterized Constructor in Java A parameterized constructor is a special type of class constructor that accepts parameters/arguments when creating an object. Unlike a default (no-arg) constructor, it allows you to initialize an object with specific values at the time of creation. Syntax The Following is the syntax: public class ClassName { private dataType field1; private dataType field2; // Parameterized ... Read More

Method Overloading vs Method Overriding in Java

Kiran Kumar Panigrahi
Updated on 09-Apr-2025 19:32:25

36K+ Views

Both Overloading and Overriding are principles of object-oriented programming. Method overloading is a type of static polymorphism in which, we can define multiple methods with the same name but with different parameters. Method Overriding is a mechanism to achieve runtime polymorphism where the super class and the sub-class have same methods, including the parameters and signature. The JVM calls the respective method based on the object used to call the method. Object-oriented programming, in short OOP, is a computer programming paradigm that organizes software design around objects, rather than functions. Method Overloading in Java When a class has two or ... Read More

Finally Block in Java Execution Cases

Shriansh Kumar
Updated on 09-Apr-2025 19:24:41

1K+ 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

How to Write Long Strings in Multi Lines C++

George John
Updated on 09-Apr-2025 19:15:32

14K+ Views

To write long strings in multi-lines, you can use 'newline character' or 'raw string literal'. It increases the readability of the code, makes the code look clean, and you can avoid scrolling. In this article, we have a long string and our task is to write the long string in multi-lines in C++. Approaches to Write Long Strings in Multi Lines Here is a list of approaches to write long strings in multiple lines which we will be discussing in this article with stepwise explanation and complete example codes. Using Newline Character ... Read More

Find Length of Array in C++

George John
Updated on 09-Apr-2025 19:14:40

21K+ Views

To find the length of an array in C++, we can use various functions and approaches that we are going to discuss in this article. Finding the length of an array is a very common task and is used in looping through an array, sorting the array, finding maximum and minimum, and in many more scenarios. In this article, we have an array and our task is to find the length of the array in C++. Approaches to Find Length of Array Here is a list of approaches to find the length of an array in C++ which ... Read More

Online C++ Variable Length Array Implementation

Tapas Kumar Ghosh
Updated on 09-Apr-2025 19:05:12

6K+ Views

Variable length arrays can have a size as required by the user i.e they can have a variable size. A Variable−Length Array (VLA) is an array whose length is determined at runtime (not compile-time). Variable Length Array Using Vector A vector is defined by the resizable array that is part of data structures and is used to store multiple elements from the same data type. A variable length array can be created using the Vector. Syntax Following are the syntaxes that uses to modify the size dynamically using vector − // inserting the array element push_back() and, // ... Read More

Parallel Array Implementation in C++

Tapas Kumar Ghosh
Updated on 09-Apr-2025 19:02:54

5K+ Views

A parallel array is a structure that contains multiple arrays. Each of these arrays are of the same size and the array elements are related to each other. All the elements in a parallel array represent a common entity. Here, we provide the basic example to understand the parallel array in C++ − employee_name = { Harry, Sally, Mark, Frank, Judy } employee_salary = {10000, 5000, 20000, 12000, 5000} Here, The name and salary of 5 different employees is stored in two different arrays. Example of Parallel Arrays This is an implementation of a parallel array ... Read More

C++ Program for Finding Nth Term of H.P.

AYUSH MISHRA
Updated on 09-Apr-2025 18:56:09

15 Views

What is Harmonic Progression? A Harmonic Progression is a sequence of numbers formed by the reciprocal of an Arithmetic progression sequence. If a given sequence a1, a2, a3, a4... is in Arithmetic progression, then 1/a1, 1/a2, 1/a3, 1/a4... forms a Harmonic Progression. Formula for the nth term of Harmonic Progression? The formula for the nth term of a Harmonic Progression is: Tn = 1 / (1/a1 + (n - 1) * d) where: a1 is the first term of the Harmonic Progression. d is the common difference of the corresponding Arithmetic ... Read More

1 2 3 4 5 ... 7937 Next
Advertisements