GeeksforGeeks

A computer science portal for geeks

Browsing the topic GFacts

In Java, constructor of base class with no argument gets automatically called in derived class constructor. For example, output of following program is:

Read More »

Size of dynamically allocated memory can be changed by using realloc(). As per the C99 standard:

Read More »

Unlike C++, arrays are first class objects in Java. For example, in the following program, size of array is accessed using length which is a member of arr[] object.

Read More »

Unlike C/C++, Java does not have goto statement, but java supports label. The only place where a label is useful in Java is right before nested loop statements. We can specify label name with break to break out a specific outer loop. Similarly, label name can be specified with continue.

Read More »

Shadowing of static functions in Java: In Java, if name of a derived class static function is same as base class static function then the derived class static function shadows (or conceals) the base class static function. For example, the following Java code prints “A.fun()”

Read More »

In C++, namespaces can be nested, and resolution of namespace variables is hierarchical. For example, in the following code, namespace inner is created inside namespace outer, which is inside the global namespace.

Read More »

Predict the output of following program.

Read More »

Exception Handling – catching base and derived classes as exceptions: If both base and derived classes are caught as exceptions then catch block of derived class must appear before the base class.

Read More »

In C/C++, precedence of Prefix ++ (or Prefix –) and dereference (*) operators is same, and precedence of Postfix ++ (or Postfix –) is higher than both Prefix ++ and *.

Read More »

In C/C++, when a character array is initialized with a double quoted string and array size is not specified, compiler automatically allocates one extra space for string terminator ‘\0′. For example, following program prints 6 as output.

Read More »

Atomic Operation What is an atomic operation? An idea of atomic operation helps in understanding reentrancy, critical section, thread safety, synchronization primitives, etc… (we will have upcoming articles on each).

Read More »

In C, a structure cannot have static members, but in C++ a structure can have static members.

Read More »

Assigning values to static final variables in Java: In Java, non-static final variables can be assigned a value either in constructor or with the declaration. But, static final variables cannot be assigned value in constructor; they must be assigned a value with their declaration.

Read More »

Type difference of character literals in C and C++ Every literal (constant) in C/C++ will have a type information associated with it.

Read More »

In C, if an object that has static storage duration is not initialized explicitly, then:

Read More »

const Behaviour in C and C++ In C, the const qualified identifiers will have external linkage, where as in C++ it will have internal linkage. For example,

Read More »

In C switch statement, the expression of each case label must be an integer constant expression.

Read More »

Like C++, Java automatically creates default constructor if there is no default or parameterized constructor written by user, and (like C++) the default constructor automatically calls parent default constructor. But unlike C++, default constructor in Java initializes member data variable to default values

Read More »

In C, struct keyword must be used for declaring structure variables, but it is optional in C++.

Read More »

In Java, when final keyword is used with a variable of primitive data types (int, float, .. etc), value of the variable cannot be changed.

Read More »

Unlike C/C++, static local variables are not allowed in Java. For example, following Java program fails in compilation with error “Static local variables are not allowed”

Read More »

In Java, all objects are dynamically allocated. When we only declare a variable of a class type, Java just creates a reference. To allocate memory to an object, we must use new().

Read More »

In Java, parameters are always passed by value. For example, following program prints i = 10, j = 20.

Read More »

In C/C++, initialization of a multidimensional arrays can have left most dimension as optional. Except the left most dimension, all other dimensions must be specified.

Read More »

Default virtual behavior of methods is opposite in C++ and Java:

Read More »