Skip to content
All Basic Articles
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… 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.… Read More
In C, if an object that has static storage duration is not initialized explicitly, then: — if it has pointer type, it is initialized to… Read More
In C++ switch statement, the expression of each case label must be an integer constant expression. For example, the following program fails in compilation. /*… 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… Read More
In C, struct keyword must be used for declaring structure variables, but it is optional in C++. For example, following program gives error 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… Read More
In Java, all objects are dynamically allocated on Heap. This is different from C++ where objects can be allocated memory either on Stack or on… Read More
See this for detailed description. 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. For… Read More
Following relationship holds in any n-ary tree in which every node has either 0 or n children. L = (n-1)*I + 1 Where L is… Read More
In C and C++, comma is the last operator in precedence table. So comma should be carefully used on right side of an assignment expression.… Read More
In C++, following are the general rules for operator overloading. 1) Only built-in operators can be overloaded. New operators can not be created. 2) Arity… Read More
In C++, once a member function is declared as a virtual function in a base class, it becomes virtual in every class derived from that… Read More
Given a root of a tree, and an integer k. Print all the nodes which are at k distance from root. For example, in the… Read More
In C printf(), %n is a special format specifier which instead of printing something causes printf() to load the variable pointed by the corresponding argument… Read More
In C++, delete operator should only be used either for the pointers pointing to the memory allocated using new operator or for a NULL pointer,… Read More
Following are the differences between malloc() and operator new.:  Calling Constructors: new calls constructors, while malloc() does not. In fact primitive data types (char, int,… Read More
Predict the output of below C++ programs. Question 1 // Assume that integers take 4 bytes. #include<iostream>    using namespace std;       class Test {… Read More