NEW
Font size
Worksheetsprogramming quiz
Total questions: 25
Worksheet time: 25mins
public class A
{ public static void main(String args[])
{ //\u000d System.out.println("hello");
} }
Hello
hello
HELLO
Error
\u000dhello
What will be the output of the following code ?
public class _C {
private static int $;
public static void main(String main[]) {
String a_b;
System.out.print($);
System.out.print(a_b);
} }
Compiler error at line 1.
Compiler error at line 2.
Compiler error at line 4.
Compiler error at line 5.
Compiler error at line 8.
What is the output for this code in python?
a, b* = 1, 2, 3
print(a, b)
1 (2, 3)
1 [2, 3]
1 ,2 3
1 {2, 3}
What is the output for this code in python?
a = []
print(not a)
False
0
True
1
Null
What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{int arr[] = {1, 2, 3, 4, 5};
for ( int i = 0; i < arr.length - 2; ++i)
System.out.println(arr[i] + " ");}
}
012
345
234
What will be the output of the following Java code?
class output
{
public static void main(String args[])
{String c = "Hello i love java";
boolean var;
var = c.startsWith("hello");
System.out.println(var);
}}
True
0
1
Which of the following declaration is not supported by C language?
String str;
char *str;
float str = 3e2;
Both “String str;” and “float str = 3e2;”
What will be the output of the following Python code snippet?
def example(a):
a = a + '2'
a = a*2
return a
>>>example("hello")
indentation Error
cannot perform mathematical operation on strings
hello2
hello2hello2
When an expression consists of int, double, long, float, then the entire expression will get promoted into a data type that is:
float
double
int
long
What is the output for the following code?
a = [1,2,3,4,5]
a[2] = 8
print(a)
[1,8,3,4,5]
[1,2,3,8,5]
[1,2,8,5,3]
Which one of the following is a loop construct that will always be executed once?
for
while
switch
do while
Which function is used to read a line of text including spaces from the user in C?
scanf()
getc()
fgets()
All of the above
main()
{ int a = 1, b = 2, c = 3;
printf("%d", a + = (a + = 3, 5, a))
}
What will be the output for the following code?
2
5
1
What is meant by ‘a’ in the following C operation?
fp = fopen("Random.txt", "a");
Attach
Append
Apprehend
Add
What will be the output of the following Python code?
x = 'abcd'
for i in range(len(x)):
print(i)
3210
1234
2345
Identify the output for the following python code?
a = ["apple", "banana", "cherry"]
a.remove("banana")
print(a)
['apple', 'cherry']
['banana','cherry']
['cherry','apple']
['cherry','banana']
What will be print on the console?
import java.util.Arrays;
public class SplitString
{ public static void main(String args[])
{ String str="Java|Python|Hadoop";
String[] array = str.split("\\|");
System.out.println(Arrays.toString(array));
} }
[Java\\ Python\\ Hadoop]
[Java|Python|Hadoop]
[Java\\|Python\\|Hadoop]
[Java, Python, Hadoop]
What is the value of the expression 7%3 in java?
1
2
3
0
Which package in java contains classes for event handling?
java.util
java.swing
java.awt.event
java.io
Which of the following is not a valid identifier for a java variable?
my_var
_myVar
3rdVar
$var
Which of the following data types in python is used to store key-value pairs?
Dictionary
List
Tuple
Set
What will be the output for the following python code snippet?
d1 = {"john" : 40 ,"peter" : 45}
d2 = {"john" : 466 ,"peter" : 45}
d1 > d2
True
False
Error
None
What is the output for the following python code?
Suppose d={"john" : 40 , "peter" : 45} , to delete the entry for "john" what command do we use?
d.delete("john" : 40)
d.delete("john")
del d["john"]
del d["john" : 4]
What will be the output?
class One{
final int a = 15;}
class Two extends One
{ final int a = 20;
}
public class Test extends Two
{ final int a = 30;
public static void main(String args[]) {
Test t = new One();
System.out.print(t. a);}
}
15
20
Compiler error
None of these
What will be the output of the following python function?
min ( max ( False , -3 , -4 ) , 2 , 7 )
2
False
-3
-4
