What is Bitwise XOR in C++

Akansha Kumari
Updated on 18-Apr-2025 19:39:12

607 Views

The XOR operator(^), also known as "exclusive OR", is one of the types of bitwise operators, which compares each bit of the first operand to the corresponding bit of the second operand and returns 1 if both bits are different, else returns 0 if both are the same. This only works with integral data types like int, char, short, long, and unsigned int, etc, and cannot be directly used with float, double, string, and class/struct objects, etc. Syntax Here is the following syntax of Bitwise XOR. result = operand1 ^ operand2; Where operand1 and operand2 are the integral types (like ... Read More

Explain Function of Operator in Python

Akshitha Mote
Updated on 18-Apr-2025 19:16:17

703 Views

The % symbol in Python is defined as the modulo operator. It can also called as remainder operator. It returns the remainder of the division of two numeric operands (except complex numbers). The Python modulo % operator is a part of arithmetic operations like addition (+), subtraction (-), multiplication (*), division (/), exponential (**), and floor division (//). The following is the basic syntax for the % modulo operator - x % y Modulo Operation on Integers When we perform a modulo operation on two integers, the result is the remainder of the division, ... Read More

Python Ternary Conditional Operator

Akshitha Mote
Updated on 18-Apr-2025 19:13:45

362 Views

The Python ternary operator returns a value based on whether a condition is True or False. It is similar to an if-else statement but is expressed in a single line. For understanding the ternary operator, we need to have an idea about conditional statements. Let's have a basic understanding of the if-else statement. We will have an if block followed by an else block here. The if block is executed when the given condition is True,  and the else block is executed if the given condition is False. The following is the basic syntax of the if-else statement - if condition: ... Read More

Convert Number String to Integers in C++

Farhan Muhamed
Updated on 18-Apr-2025 19:02:00

502 Views

There are several inbuilt functions and objects to convert a number string to an integer in C++. Every method has its own advantages and disadvantages. In this article, we will discuss all the approaches to convert a number string to an integer in C++ with example code and use cases. Number String to Integer Conversion Here is the list of approaches to convert a number string to an integer in C++, which we will be discussing in this article with stepwise explanation and complete example codes. Convert Using stoi() Function ... Read More

Extract All Integers from String in C++

Farhan Muhamed
Updated on 18-Apr-2025 18:54:43

7K+ Views

In this article, we will discuss how to extract all the integers from a string using C++ program. We will explore all the possible approaches to do so. First of all, let's understand the problem statement. We have a string that contains a mix of digits and non-digits. We need to extract all the integers from the string and store them in a vector. The integers can be positive or negative. For example, // Input String string str = "ab24wj-123fow" // Output Vector vector vec = {24, -123} Approaches to Extract Integers from String ... Read More

Check if String is Pangram in Java

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 - Input: "The quick brown fox jumps over the lazy dog" Output: Yes, the string is a pangram Read the input String, you can find all the letters of the English alphabet in it. Therefore, it is a pangram string. How to Check if a String is a Pangram ... Read More

HAS-A Relationship in Java

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 other in many ways such as, Is-A relationship and Has-A relationship. In this article, we are going to learn the concept of Has-A relationship in Java through examples. HAS-A Relationship in Java Has-A relationship is a type of association where two classes are linked to each other through objects. Here, ... Read More

Restrictions on Static Methods and Static Blocks in Java

Maruthi Krishna
Updated on 18-Apr-2025 18:32:45

5K+ Views

Static Methods and Static Blocks Static methods belong to the class and they will be loaded into memory along with the class; you can invoke them without creating an object. (using the class name as reference). Whereas a static block is a block of code with a static keyword. In general, these are used to initialize the static members. JVM executes static blocks before the main method at the time of class loading. Example The following example demonstrates the usage of static blocks and static methods in Java - public class Sample { ... Read More

Types of Memory Areas Allocated by JVM in Java

Maruthi Krishna
Updated on 18-Apr-2025 18:17:44

2K+ Views

Java Virtual Machine is a program/software that runs Java applications. It takes Java bytecode (.class files) and converts the bytecode (line by line) into machine-understandable code, line by line so the processor can understand and execute it. JVM contains a module(components) known as a class loader. It is responsible for loading the program into memory and preparing it to run. Class Loader performs three main tasks - It Loads the class into the memory. ... Read More

Handle EOFException in Java

Maruthi Krishna
Updated on 18-Apr-2025 18:14:21

2K+ Views

While reading the contents of a file using a Java program, we may reach the end of the file abruptly; in such cases, EOFException (End Of File) is thrown. Especially, this exception occurs while reading data using the InputStream objects, such as DataInputStream. In other scenarios, a specific value will be thrown when the end of the file is reached. Why Does the EOFException Occur The EOFException occurs when a stream reaches the end of the file while reading its contents. If we consider the DataInputStream class, it provides various methods such as readBoolean(), readByte(), readChar(), etc, to read primitive ... Read More

Advertisements