WorksheetsDEBUGGING
Total questions: 26
Worksheet time: 13mins
1. What is the output of the following program?
#include<stdio.h>
main()
{
fprintf(stdout,"Hello, World!");
}
A . Hello, World!
B. No output
C . Compile error
D . Runtime error
2.What is the output of the following program?
#include<stdio.h>
int main();
void main()
{
printf("Okay");
}
A . Okay
B. No output
C . Compile error. We can not declare main() function.
D. Compile error. Mismatch in declaration & definition.
3- Which scanf() statement will you use to scan a float value (a) and double value (b)?
Float a;
Double b;
A. scanf("%f %f", &a, &b);
B. scanf("%lf % lf ", &a, &b);
C. scanf("%Lf %Lf", &a, &b);
D. scanf("%f %lf", &a, &b);
4 - An operation with only one operand is called unary operation.
A . Yes
B . An operation with two operand is called unary operation
C . An operation with unlimited operand is called unary operation
D. None of the above
5 - Choose the function that is most appropriate for reading in a multi-word string?
A. strnset()
B. scanf()
C. strchr()
D. gets()
6. What is the correct value to return to the operating system upon the successful completion of a program?
A. -1
B. 1
C.0
D. Programs do not return a value
7. Which of the following is a correct comment?
A. */ Comments */
B. ** Comment **
C. /* Comment */
D. { Comment }
8. Which of the following is not a correct variable type?
A. float
B. real
C. int
D. double
9. - Choose the correct syntax for reading from a text file stored in ‘‘c:\scores.txt’’ ?
A . Infile = open(''c:\scores.txt'',''r'')
B . Infile = open(file=''c:\\\scores.txt'', ''r'')
C . Infile = open.file(''c:\\scores.txt'',''r'')
D . Infile = open(''c:\\scores.txt'', ''r'')
10 - What command is used to shuffle a list ‘L’?
A . L.shuffle()
B . random.shufflelist(L)
C . shuffle(L)
D . random.Shuffle(L)
11 - What is output of following code −
def func(n):
if(n==1):
return 1;
else:
return(n+func(n-1))
print(func(4))
A . 12
B . 10
C . 9
D . 11
12. Which of the following is false statement in python
A - int(144)==144
B - int('144')==144
C - int(144.0)==144
D - None of the above
13.What does the following code print?
a = [1, 2, 3]
a is a[:]
A. True
B.False
C. This code raises an exception
D. Error
14. What is the output of print(2%6)
A. ValueError
B. 0.33
C. 2
D. 3
15. Which of the following operators has the highest precedence?
A. Not
B. &
C. *
D. +
16. What is the output of the following code
print(bool(0), bool(3.14159), bool(-3), bool(1.0+1j))
A. True True False True
B. False True True True
C. True True False True
D. False True False True
17. What is the output of the following code
x = 100
y = 50
print(x and y)
A. True
B. 100
C. False
D. 50
18. What kind of variables a class can consist of?
A . class variables, instance variables
B . class variables, local variables, instance variables
C . class variables
D . class variables, local variables
19. java.util.Collections is a:
A. Class
B. Interface
C. Object
D. None of the above
20. Given the code
String s1 = ” yes” ;
String s2 = ” yes ” ;
String s3 = new String ( s1);
Which of the following would equate to true?
A. s1 == s2
B. s1 = s2
C. s3 == s1
D. s3=s1
21. Which one of these is a valid method declaration?
A. void method1
B. void method2()
C. void method3(void)
D. method4()
22. What does the expression float a = 35 / 0 return?
A. 0
B. Not a Number
C. Infinity
D. Run time exception
23. Which of the following creates a List of 3 visible items and multiple selections abled?
A. new List(false, 3)
B. new List(3, true)
C. new List(true, 3)
D. new List(3, false)
24. Which of the following for loop declaration is not valid?
A. for ( int i = 99; i >= 0; i / 9 )
B. for ( int i = 7; i <= 77; i += 7 )
C. for ( int i = 20; i >= 2; - -i )
D. for ( int i = 2; i <= 20; i = 2* i )
25. What will be the output of the following program?
public class Test2 {
public static void main(String[] args) {
StringBuffer s1 = new StringBuffer("Complete");
s1.setCharAt(1,'i');
s1.setCharAt(7,'d');
System.out.println(s1);
} }
A. Complete
B. Iomplede
C. Cimpletd
D. Coipletd
Feedback for our contest
Very Good
Good
Moderate
Poor
