Significance of Red Fort

siddhartha kotamraju
Updated on 26-Jun-2020 13:46:14

4K+ Views

The Red Fort is located in the city of Delhi in India. It has a great history as it was the main residence of Mughal emperors for nearly 200 years (until 1857).The red fort is the center of Delhi and it houses a large number of museums. Not only the accommodation for the emperors but also it was the center for Mughal state politics and for setting events that impact the region critically.Its construction was started in the year 1639 by the 5th Mughal emperor Shah Jahan as the place of his fortified capital Shahjahanabad. The name Red Fort comes ... Read More

Convert String to UTF-8 Bytes in Java

Anvi Jain
Updated on 26-Jun-2020 13:45:42

25K+ Views

Before converting a String to UTF-8-bytes, let us have a look at UTF-8.UTF-8 is a variable width character encoding. UTF-8 has ability to be as condense as ASCII but can also contain any unicode characters with some increase in the size of the file. UTF stands for Unicode Transformation Format. The '8' signifies that it allocates 8-bit blocks to denote a character. The number of blocks needed to represent a character varies from 1 to 4.In order to convert a String into UTF-8, we use the getBytes() method in Java. The getBytes() method encodes a String into a sequence of ... Read More

Initialization of Global and Static Variables in C

Arjun Thakur
Updated on 26-Jun-2020 13:45:22

5K+ Views

In C language both the global and static variables must be initialized with constant values. This is because the values of these variables must be known before the execution starts. An error will be generated if the constant values are not provided for global and static variables.A program that demonstrates the initialization of global and static variables is given as follows.Example Live Demo#include int a = 5; static int b = 10; int main() {    printf("The value of global variable a : %d", a);    printf("The value of global static variable b : %d", b);    return 0; }OutputThe ... Read More

Declare Variable as Constant in C

Ankith Reddy
Updated on 26-Jun-2020 13:44:11

20K+ Views

Variables can be declared as constant using the const keyword or the #define preprocessor directive. Details about these are given as follows.The const keywordVariables can be declared as constants by using the “const” keyword before the datatype of the variable. The constant variables can be initialized once only. The default value of constant variables are zero.A program that demonstrates the declaration of constant variables in C using const keyword is given as follows.Example Live Demo#include int main() {    const int a;    const int b = 12;    printf("The default value of variable a : %d", a);    printf("The ... Read More

Check If String Has Only Unicode Digits or Space in Java

Nancy Den
Updated on 26-Jun-2020 13:42:19

4K+ Views

In order to check if a String has only unicode digits or space in Java, we use the isDigit() method and the charAt() method with decision making statements.The isDigit(int codePoint) method determines whether the specific character (Unicode codePoint) is a digit. It returns a boolean value, either true or false.Declaration - The java.lang.Character.isDigit() method is declared as follows −public static boolean isDigit(int codePoint)The charAt() method returns a character value at a given index. It belongs to the String class in Java. The index must be between 0 to length()-1.Declaration − The java.lang.String.charAt() method is declared as follows −public char charAt(int ... Read More

When Are Static C++ Class Members Initialized

Arjun Thakur
Updated on 26-Jun-2020 13:41:03

561 Views

Static C++ class members can be defined using the static keyword. The static member in a class is shared by all the class objects as there is only one copy of the static class member in the memory, regardless of the number of objects of the class.The static class member is initialized to zero when the first object of the class is created if it is not initialized in any other way.A program that demonstrates static class members in C++ is given as follows.Example Live Demo#include using namespace std; class Example {    public :    static int a;   ... Read More

When to Use a Class vs a Struct in C++

Chandu yadav
Updated on 26-Jun-2020 13:36:53

446 Views

Structures and classes are very similar in C++ except for some differences. So details about these differences are given below that help to decide when to use a class or structure in C++.Differences between Class and StructureAll the members of a class are private by default. This is different compared to structures as all the members of a structure are public by default.A program that demonstrates a class in C++ is given as follows −Example#include using namespace std; class Example {    int val; }; int main() {    Example obj;    obj.val = 20;    return 0; }This ... Read More

Check If a String Has Only Unicode Digits in Java

Smita Kapse
Updated on 26-Jun-2020 13:33:42

541 Views

In order to check if a String has only unicode digits in Java, we use the isDigit() method and charAt() method with decision making statements.The isDigit(int codePoint) method determines whether the specific character (Unicode codePoint) is a digit. It returns a boolean value, either true or false.Declaration − The java.lang.Character.isDigit() method is declared as follows −public static boolean isDigit(int codePoint)where the parameter codePoint represents the character to be checked.The charAt() method returns a character value at a given index. It belongs to the String class in Java. The index must be between 0 to length()-1.Declaration − The java.lang.String.charAt() method is ... Read More

Print Stack Trace in Java

Krantik Chavan
Updated on 26-Jun-2020 13:32:02

6K+ Views

In order to print the stack trace in Java, we use the java.lang.Throwable.printStackTrace() method. The printStackTrace() method prints the throwable and its backtrace in the standard error stream.Declaration - The java.lang.Throwable.printStackTrace() method is declared as follows −public void printStackTrace()Let us see a program to print the stack trace in Java.Example Live Demopublic class Example {    public static void main(String args[]) throws Throwable {       try {          int n = 3;          System.out.println(n/0);       } catch (ArithmeticException e) {          System.out.println("Printing stack trace...");         ... Read More

Private and Protected Members in C++

Arjun Thakur
Updated on 26-Jun-2020 13:29:23

8K+ Views

A class in C++ has public, private and protected sections which contain the corresponding class members.The private data members cannot be accessed from outside the class. They can only be accessed by class or friend functions. All the class members are private by default.The protected members in a class are similar to private members but they can be accessed by derived classes or child classes while private members cannot.A program that demonstrates private and protected members in a class is given as follows −Example Live Demo#include using namespace std; class Base {    public :    int a = 8; ... Read More

Advertisements