Category Archives: Output

Output of C programs | Set 29

Question 1 Here, it would seem that, as ‘i’ got assigned a value 10, so the loop will run only one time because the loop condition will fail as ‘i’ becomes 11 the next time it enters the loop. But the output is quite different than what we expected. The reason behind this is the… Read More »

Output of Python program | Set 5

Predict the output of the following programs: Program 1: Output: cool Explanation: There is a docstring defined for this method, by putting a string on the first line after the start of the function definition. The docstring can be referenced using the __doc__ attribute of the function. And hence it prints the indexed string. Program… Read More »

Output of Java Program | Set 9

Difficulty level : Intermediate Predict the output of following Java Programs. Program 1: Output: Geeksforgeeks Geeksforgeeks Explanation: We know that static variables are called when a class loads and static variables are called only once. Now line 13 results to creation of object which inturn calls the constructor and “Geeksforgeeks” is printed second time. If… Read More »

Output of Java Program | Set 8

Difficulty level : Intermediate Predict the output of following Java Programs. Program 1: Output: Not equal Explanation: Since, s1 and s2 are two different objects the references are not the same, and the == operator compares object reference. So it prints “Not equal”, to compare the actual characters in the string .equals() method must be… Read More »

Output of Python Program | Set 3

Difficulty level : Intermediate Predict the output of following Python Programs. Program 1: Output: 51 Explanation : In the above program we are creating a member variable having name ‘life’ by adding it directly to the dictionary of the object ‘manager’ of class ‘Geeks’. Total numbers of items in the dictionary is 2, the variables… Read More »

Output of Java Program | Set 6

Difficulty level : Intermediate Predict the output of following Java Programs. Program 1: Output: a b c Explanation: While creating a new object of ‘Third’ type, before calling the default constructor of Third class, the default constructor of super class is called i.e, Second class and then again before the default constructor of super class,… Read More »

Output of Python Program | Set 1

Predict the output of following python programs: Program 1: Output: 24 Explanation : In the above program r and s are lambda functions or anonymous functions and q is the argument to both of the functions. In first step we have initialized x to 2. In second step we have passed x as argument to… Read More »

Output of Java program | Set 5

Predict the output of following Java Programs. Program 1: Output: String Explanation : In case of method overloading, the most specific method is chosen at compile time. As ‘java.lang.String’ is a more specific type than ‘java.lang.Object’. In this case the method which takes ‘String’ as a parameter is choosen. Program 2: Output: Compile Error at… Read More »

Output of C++ Program | Set 19

Predict the output below program Explanation:- It is based on fact that how LOGICAL – OR and LOGICAL-AND work. Note that Compiler reads OR and AND operators from left to right. Let us take the following cases into consideration:- Output: 1 2 1 Once compiler detects “true” on the LEFT of logical OR, IT IS… Read More »