wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DEBUGGING

Total questions: 26

Worksheet time: 13mins

Name
Class
Date
1.

1. What is the output of the following program?

#include<stdio.h>


main()

{

fprintf(stdout,"Hello, World!");

}

a)

A . Hello, World!

b)

B. No output

c)

C . Compile error

d)

D . Runtime error

2.

2.What is the output of the following program?

#include<stdio.h>


int main();

void main()

{

printf("Okay");

}

a)

A . Okay

b)

B. No output

c)

C . Compile error. We can not declare main() function.

d)

D. Compile error. Mismatch in declaration & definition.

3.

3- Which scanf() statement will you use to scan a float value (a) and double value (b)?


Float a;

Double b;

a)

A. scanf("%f %f", &a, &b);

b)

B. scanf("%lf % lf ", &a, &b);

c)

C. scanf("%Lf %Lf", &a, &b);

d)

D. scanf("%f %lf", &a, &b);

4.

4 - An operation with only one operand is called unary operation.

a)

A . Yes

b)

B . An operation with two operand is called unary operation

c)

C . An operation with unlimited operand is called unary operation

d)

D. None of the above

5.

5 - Choose the function that is most appropriate for reading in a multi-word string?

a)

A. strnset()

b)

B. scanf()

c)

C. strchr()

d)

D. gets()

6.

6. What is the correct value to return to the operating system upon the successful completion of a program?

a)

A. -1

b)

B. 1

c)

C.0

d)

D. Programs do not return a value

7.

7. Which of the following is a correct comment?

a)

A. */ Comments */

b)

B. ** Comment **

c)

C. /* Comment */

d)

D. { Comment }

8.

8. Which of the following is not a correct variable type?

a)

A. float

b)

B. real

c)

C. int

d)

D. double

9.

9. - Choose the correct syntax for reading from a text file stored in ‘‘c:\scores.txt’’ ?

a)

A . Infile = open(''c:\scores.txt'',''r'')

b)

B . Infile = open(file=''c:\\\scores.txt'', ''r'')

c)

C . Infile = open.file(''c:\\scores.txt'',''r'')

d)

D . Infile = open(''c:\\scores.txt'', ''r'')

10.

10 - What command is used to shuffle a list ‘L’?

a)

A . L.shuffle()

b)

B . random.shufflelist(L)

c)

C . shuffle(L)

d)

D . random.Shuffle(L)

11.

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)

A . 12

b)

B . 10

c)

C . 9

d)

D . 11

12.

12. Which of the following is false statement in python

a)

A - int(144)==144

b)

B - int('144')==144

c)

C - int(144.0)==144

d)

D - None of the above

13.

13.What does the following code print?

a = [1, 2, 3]

a is a[:]

a)

A. True

b)

B.False

c)

C. This code raises an exception

d)

D. Error

14.

14. What is the output of print(2%6)

a)

A. ValueError

b)

B. 0.33

c)

C. 2

d)

D. 3

15.

15. Which of the following operators has the highest precedence?

a)

A. Not

b)

B. &

c)

C. *

d)

D. +

16.

16. What is the output of the following code

print(bool(0), bool(3.14159), bool(-3), bool(1.0+1j))

a)

A. True True False True

b)

B. False True True True

c)

C. True True False True

d)

D. False True False True

17.

17. What is the output of the following code

x = 100

y = 50

print(x and y)

a)

A. True

b)

B. 100

c)

C. False

d)

D. 50

18.

18. What kind of variables a class can consist of?

a)

A . class variables, instance variables

b)

B . class variables, local variables, instance variables

c)

C . class variables

d)

D . class variables, local variables

19.

19. java.util.Collections is a:

a)

A. Class

b)

B. Interface

c)

C. Object

d)

D. None of the above

20.

20. Given the code

String s1 = ” yes” ;

String s2 = ” yes ” ;

String s3 = new String ( s1);

Which of the following would equate to true?

a)

A. s1 == s2

b)

B. s1 = s2

c)

C. s3 == s1

d)

D. s3=s1

21.

21. Which one of these is a valid method declaration?

a)

A. void method1

b)

B. void method2()

c)

C. void method3(void)

d)

D. method4()

22.

22. What does the expression float a = 35 / 0 return?

a)

A. 0

b)

B. Not a Number

c)

C. Infinity

d)

D. Run time exception

23.

23. Which of the following creates a List of 3 visible items and multiple selections abled?

a)

A. new List(false, 3)

b)

B. new List(3, true)

c)

C. new List(true, 3)

d)

D. new List(3, false)

24.

24. Which of the following for loop declaration is not valid?

a)

A. for ( int i = 99; i >= 0; i / 9 )

b)

B. for ( int i = 7; i <= 77; i += 7 )

c)

C. for ( int i = 20; i >= 2; - -i )

d)

D. for ( int i = 2; i <= 20; i = 2* i )

25.

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)

A. Complete

b)

B. Iomplede

c)

C. Cimpletd

d)

D. Coipletd

26.

Feedback for our contest

a)

Very Good

b)

Good

c)

Moderate

d)

Poor