Computer Programming Exam - 100
Objective Questions
1. Which of the following is not a programming language?
a) Python
b) Java
c) HTML
d) C
2. The process of finding and fixing errors in a program is called:
a) Compiling
b) Debugging
c) Interpreting
d) Executing
3. Which of the following is a low-level language?
a) Assembly
b) Java
c) Python
d) C++
4. The set of rules for writing programs in a language is called:
a) Algorithm
b) Syntax
c) Pseudocode
d) Flowchart
5. Which of the following translates high-level code into machine code?
a) Editor
b) Compiler
c) Linker
d) Debugger
6. In C, the default return type of a function is:
a) int
b) void
c) float
d) char
7. Which data type is used to store a single character in Java?
a) char
b) string
c) int
d) boolean
8. The keyword used to declare a constant in C++ is:
a) const
b) define
c) static
d) final
9. Which of the following represents a floating-point literal?
a) 10
b) 10.5
c) 'A'
d) "Hello"
10. In Python, the type of 3/2 is:
a) int
b) float
c) double
d) complex
11. Which operator has the highest precedence in C?
a) *
b) ()
c) ++
d) %
12. In Java, == checks for:
a) Value equality
b) Reference equality
c) Both
d) None
13. The result of 5 % 2 is:
a) 0
b) 1
c) 2
d) 2.5
14. Which operator is used for logical AND in Python?
a) &&
b) and
c) &
d) &&&
15. The bitwise NOT operator in C is:
a) !
b) ~
c) ^
d) %
16. Which loop checks the condition after execution?
a) for
b) while
c) do-while
d) foreach
17. Which keyword is used to exit from a loop?
a) continue
b) exit
c) break
d) return
18. In Python, elif is used in place of:
a) else if
b) elseif
c) switch
d) select
19. The switch statement cannot be used with:
a) int
b) char
c) string (in C)
d) enum
20. The continue statement:
a) Ends the loop
b) Skips the current iteration
c) Restarts program
d) Exits program
21. A function that calls itself is known as:
a) Overloaded function
b) Recursive function
c) Virtual function
d) Inline function
22. In C, the main function returns:
a) char
b) void
c) int
d) float
23. Default arguments in C++ functions must be:
a) On the leftmost side
b) On the rightmost side
c) In the middle
d) Anywhere
24. In Python, def keyword is used for:
a) Defining class
b) Defining function
c) Defining module
d) Defining variable
25. Which function is automatically called when a class object is created?
a) main()
b) init()
c) constructor
d) destructor
26. The index of the first element in an array is:
a) -1
b) 0
c) 1
d) Any
27. In C, strings are terminated with:
a) Null (\0)
b) Space
c) Tab
d) Newline
28. In Java, arrays are:
a) Objects
b) Pointers
c) Functions
d) None
29. Which function in C is used to find the length of a string?
a) strlen()
b) sizeof()
c) length()
d) strlength()
30. In Python, slicing s[0:3] extracts:
a) First 3 characters
b) Last 3 characters
c) Middle characters
d) None
31. Which operator is used to access the value at the address stored in a pointer?
a) &
b) *
c) ->
d) %
32. The address-of operator is:
a) &
b) *
c) @
d) #
33. A pointer that does not point to any memory location is called:
a) Dangling pointer
b) Null pointer
c) Void pointer
d) Wild pointer
34. In C, dynamic memory allocation is done using:
a) malloc()
b) calloc()
c) realloc()
d) All of the above
35. Which of the following is not a valid pointer type?
a) void *
b) int *
c) float *
d) string *
36. Which OOP concept allows reusing code?
a) Polymorphism
b) Encapsulation
c) Inheritance
d) Abstraction
37. Wrapping data and functions into a single unit is:
a) Abstraction
b) Encapsulation
c) Polymorphism
d) Modularity
38. The process of defining multiple functions with the same name but different parameters
is:
a) Overloading
b) Overriding
c) Encapsulation
d) Inheritance
39. Which of the following is a destructor in C++?
a) ~ClassName()
b) delete()
c) free()
d) destroy()
40. Which access specifier makes members accessible only inside the class?
a) public
b) private
c) protected
d) static
41. In C, the default file mode for fopen() is:
a) w
b) r
c) a
d) rw
42. Which function is used to read a single character from a file?
a) fread()
b) getc()
c) fgets()
d) scanf()
43. In Java, which class is used for file handling?
a) File
b) Files
c) Reader
d) Writer
44. In Python, the mode "w" means:
a) Read only
b) Write only (overwrite)
c) Append
d) Read and write
45. Which function is used to close a file in C?
a) stop()
b) fclose()
c) end()
d) exit()
46. A step-by-step procedure to solve a problem is called:
a) Flowchart
b) Algorithm
c) Syntax
d) Program
47. Which of the following is not an operating system?
a) Windows
b) Linux
c) Compiler
d) MacOS
48. Which of the following is not a valid identifier in C?
a) myVariable
b) 123abc
c) _temp
d) var1
49. Which keyword is used to define a class in Python?
a) define
b) defclass
c) class
d) object
50. In Java, JVM stands for:
a) Java Variable Machine
b) Java Virtual Machine
c) Java Visual Machine
d) Java Verified Machine