wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming with Java C++ and Python

Total questions: 109

Worksheet time: 55mins

Name
Class
Date
1.
In Java which of these is NOT a valid collection interface?
a)
Collection
b)
List
c)
Set
d)
Array
2.
In Java which of these is NOT a valid method to start a thread?
a)
start()
b)
run()
c)
execute()
d)
begin()
3.
In Java which of these is NOT a valid exception type?
a)
RuntimeException
b)
IOException
c)
SQLException
d)
LogicException
4.
In Java which of these is NOT a valid thread priority?
a)
MIN_PRIORITY
b)
NORM_PRIORITY
c)
MAX_PRIORITY
d)
HIGH_PRIORITY
5.
In Java which of these is NOT a valid method to convert a string to an integer?
a)
Integer.parseInt()
b)
Integer.valueOf()
c)
new Integer()
d)
int.parse()
6.
In Java which of these is NOT a valid way to create a thread?
a)
extends Thread
b)
implements Runnable
c)
implements Callable
d)
extends Runnable
7.
In Java which of these is NOT a valid collection class?
a)
ArrayList
b)
LinkedList
c)
HashSet
d)
ArraySet
8.
In Java which of these is NOT a valid way to handle exceptions?
a)
try-catch
b)
throws
c)
throw
d)
raise
9.
In Java which of these is NOT a valid thread method?
a)
sleep()
b)
yield()
c)
wait()
d)
pause()
10.
In Java which of these is NOT a valid way to iterate over a collection?
a)
for-each
b)
Iterator
c)
Stream
d)
for-in
11.
In Java which of these is NOT a valid modifier for an abstract method?
a)
abstract
b)
public
c)
protected
d)
final
12.
In Java which of these is NOT a valid way to create a singleton?
a)
enum
b)
static block
c)
private constructor
d)
public constructor
13.
In Java which of these is NOT a valid thread synchronization mechanism?
a)
synchronized
b)
volatile
c)
Lock
d)
mutex
14.
In Java which of these is NOT a valid loop construct?
a)
for-each
b)
while
c)
loop
d)
do-while
15.
In Java which of these is NOT a valid array declaration?
a)
int arr[]
b)
int[] arr
c)
int arr[5]
d)
int arr[]
16.
In Java which of these is NOT a valid access level for a top-level class?
a)
package-private
b)
public
c)
protected
d)
private
17.
In Java which of these is NOT a valid loop control statement?
a)
break
b)
continue
c)
skip
d)
return
18.
In Java which of these is NOT a valid array method?
a)
length
b)
length()
c)
size()
d)
clone()
19.
In Java which of these is NOT a valid access modifier for an interface method?
a)
public
b)
private
c)
default
d)
static
20.
In Java which keyword prevents a method from being overridden?
a)
final
b)
static
c)
sealed
d)
override
21.
In Java which package contains the Scanner class?
a)
java.util
b)
java.io
c)
java.lang
d)
java.net
22.
In Java what is the default value of an uninitialized boolean instance variable?
a)
True
b)
False
c)
null
23.
In Java which collection class is synchronized by default?
a)
Vector
b)
ArrayList
c)
HashSet
d)
LinkedList
24.
In Java which modifier allows a variable to be accessed without creating an object?
a)
static
b)
final
c)
abstract
d)
volatile
25.
In Java which of these is NOT a primitive type?
a)
String
b)
int
c)
char
d)
boolean
26.
In Java which exception is thrown when an array index is out of bounds?
a)
ArrayIndexOutOfBoundsException
b)
IndexOutOfBoundsException
c)
NoSuchElementException
d)
NullPointerException
27.
In Java which keyword is used to create a subclass?
a)
extends
b)
implements
c)
inherits
d)
subclass
28.
In Java which method must be implemented by all threads?
a)
run()
b)
start()
c)
execute()
d)
main()
29.
In Java which of these is NOT a valid access modifier?
a)
package-private
b)
public
c)
protected
d)
private
30.
In Java which class is the superclass of all classes?
a)
Object
b)
Class
c)
Base
d)
Root
31.
In Java which of these is NOT a valid identifier?
a)
2variable
b)
_var
c)
$var
d)
var2
32.
In Java which of these is NOT a valid constructor modifier?
a)
synchronized
b)
public
c)
protected
d)
private
33.
In Java which of these is NOT a valid exception handling keyword?
a)
handle
b)
try
c)
catch
d)
finally
34.
In Java which of these is NOT a valid modifier for a local variable?
a)
public
b)
final
c)
static
d)
volatile
35.
In Java which of these is NOT a valid thread state?
a)
Sleeping
b)
Running
c)
Blocked
d)
Waiting
36.
In Java
a)
synchronized
b)
public
c)
protected
d)
private
37.
Which Python data structure is ordered and immutable?
a)
list
b)
dict
c)
set
38.
Which C++ feature allows a single function name to perform multiple tasks?
a)
inheritance
b)
encapsulation
c)
polymorphism
39.
Which Python keyword is used to create anonymous functions?
a)
def
b)
fun
c)
anon
40.
Which C++ access specifier allows members to be accessed within the same class and derived classes?
a)
public
b)
private
c)
internal
41.
Which Python library is most commonly used for numerical computing?
a)
Pandas
b)
TensorFlow
c)
Matplotlib
42.
Which C++ operator cannot be overloaded?
a)
++
b)
<<
43.
Which Python statement is used to handle exceptions?
a)
try-catch
b)
handle
c)
with
44.
Which C++ mechanism ensures that resources are released when objects go out of scope?
a)
garbage collection
b)
try-finally
c)
finally blocks
45.
Which Python method converts a string to an integer?
a)
str()
b)
float()
c)
chr()
46.
Which C++ feature allows template parameters to accept default types?
a)
function templates
b)
class templates
c)
explicit specialization
47.
Which Python module is used for regular expressions?
a)
regex
b)
reg
c)
regexp
48.
Which C++ container provides constant-time insertion and deletion at both ends?
a)
vector
b)
list
c)
set
49.
Which Python decorator is used to define static methods in a class?
a)
@classmethod
b)
@staticmethod
c)
@staticmethod
50.
Which C++ feature allows a derived class to inherit from multiple base classes?
a)
single inheritance
b)
interface inheritance
c)
virtual inheritance
51.
Which Python function returns the length of an object?
a)
size()
b)
length()
c)
count()
52.
Which C++ keyword is used to declare a pointer?
a)
&
b)
->
c)
.
53.
Which Python built-in function is used to open a file?
a)
file()
b)
fopen()
c)
read()
54.
Which C++ STL algorithm sorts elements in a range?
a)
qsort()
b)
sorted()
c)
order()
55.
Which Python data type is used to store key-value pairs?
a)
set
b)
list
c)
tuple
56.
Which C++ feature prevents object slicing?
a)
templates
b)
references
c)
pointers
57.
Which Python operator is used for floor division?
a)
/
b)
%
c)
**
58.
Which C++ cast is safest for downcasting polymorphic types?
a)
static_cast
b)
const_cast
c)
reinterpret_cast
59.
Which Python module is used for JSON handling?
a)
jsonlib
b)
js
c)
jsonify
60.
Which C++ container stores unique keys in sorted order?
a)
set
b)
unordered_map
c)
vector
61.
Which Python keyword is used to create a generator?
a)
return
b)
generator
c)
def
62.
Which C++ feature allows run-time type identification?
a)
sizeof operator
b)
decltype specifier
c)
auto keyword
63.
Which Python method removes whitespace from the beginning and end of a string?
a)
trim()
b)
clean()
c)
remove()
64.
Which C++ keyword is used to prevent inheritance?
a)
sealed
b)
static
c)
const
65.
Which Python built-in function returns a reversed iterator?
a)
reverse()
b)
rev()
c)
invert()
66.
Which C++ feature allows functions to accept a variable number of arguments?
a)
function overloading
b)
default arguments
c)
function pointers
67.
Which Python function is used to get the current working directory?
a)
os.getdir()
b)
os.currentdir()
c)
os.pwd()
68.
Which C++ container provides constant-time lookup by key?
a)
vector
b)
list
c)
deque
69.
Which Python keyword is used to define a class?
a)
def
b)
struct
c)
type
70.
Which C++ feature allows a function to be defined inside another function?
a)
local functions
b)
nested classes
c)
inline functions
71.
Which Python module is used for date and time manipulation?
a)
time
b)
date
c)
calendar
72.
Which C++ keyword is used to create an alias for a type?
a)
using
b)
alias
c)
type
73.
Which Python function is used to convert an object to a string representation?
a)
repr()
b)
string()
c)
to_string()
74.
Which C++ feature allows a class to have a constant member function?
a)
static keyword
b)
final keyword
c)
immutable keyword
75.
Which Python operator is used for matrix multiplication in NumPy
a)
*
b)
**
c)
dot
76.
Which C++ feature allows a base class to be inherited virtually?
a)
multiple inheritance
b)
single inheritance
c)
interface inheritance
77.
Which Python function is used to check if an object is an instance of a class?
a)
type()
b)
class()
c)
instanceof()
78.
Which C++ STL container implements a LIFO stack?
a)
queue
b)
vector
c)
deque
79.
Which Python keyword is used to import modules?
a)
include
b)
using
c)
require
80.
Which C++ feature allows a function to have default arguments?
a)
function overloading
b)
template specialization
c)
operator overloading
81.
Which Python function is used to generate random numbers?
a)
rand()
b)
randint()
c)
generate()
82.
Which C++ keyword is used to create a template class?
a)
typename
b)
class
c)
generic
83.
Which Python function is used to read a line from standard input?
a)
read()
b)
readline()
c)
scan()
84.
Which C++ STL algorithm finds an element in a range?
a)
search()
b)
locate()
c)
get()
85.
Which Python data structure is unordered and mutable?
a)
frozenset
b)
tuple
c)
str
86.
Which C++ feature allows a class to have a friend function?
a)
private keyword
b)
protected keyword
c)
public keyword
87.
Which Python method is used to add an element to the end of a list?
a)
add()
b)
insert()
c)
extend()
88.
Which C++ cast is used to remove const-ness?
a)
static_cast
b)
dynamic_cast
c)
reinterpret_cast
89.
Which Python function is used to sort a list in place?
a)
sorted()
b)
order()
c)
arrange()
90.
Which C++ feature allows a function to be inlined?
a)
const keyword
b)
static keyword
c)
virtual keyword
91.
Which Python module is used for working with CSV files?
a)
csvlib
b)
csvreader
c)
csvwriter
92.
Which C++ STL container provides a FIFO queue?
a)
stack
b)
vector
c)
deque
93.
Which Python keyword is used to define a function?
a)
function
b)
func
c)
define
94.
Which C++ feature allows a class to have a virtual destructor?
a)
~keyword
b)
delete keyword
c)
override keyword
95.
Which Python method is used to remove an element from a set by value?
a)
delete()
b)
discard()
c)
pop()
96.
Which C++ feature allows a template parameter to be a non-type parameter?
a)
template type parameter
b)
template template parameter
c)
variadic template
97.
Which Python function is used to get the absolute value of a number?
a)
absolute()
b)
fabs()
c)
magnitude()
98.
Which C++ STL algorithm reverses a range?
a)
rev()
b)
invert()
c)
flip()
99.
Which Python data type is immutable and hashable?
a)
list
b)
dict
c)
set
100.
Which C++ feature allows a class to have a static member?
a)
instance keyword
b)
class keyword
c)
const keyword
101.
Which Python function is used to convert a string to lowercase?
a)
toLowerCase()
b)
tolower()
c)
casefold()
102.
Which C++ feature allows a function to be noexcept?
a)
throw keyword
b)
const keyword
c)
final keyword
103.
Which Python module is used for working with regular expressions?
a)
regex
b)
reg
c)
regexp
104.
Which C++ STL container provides a dynamic array?
a)
array
b)
deque
c)
list
105.
Which Python method is used to join elements of a list into a string?
a)
concat()
b)
merge()
c)
combine()
106.
Which C++ feature allows a class to have a move constructor?
a)
copy constructor
b)
default constructor
c)
virtual destructor
107.
Which Python function is used to check if a file exists?
a)
os.isfile()
b)
os.fileexists()
c)
os.checkfile()
108.
Which C++ STL algorithm performs a binary search?
a)
search()
b)
find()
c)
lower_bound()
109.
Which Python data structure is ordered and mutable?
a)
set
b)
frozenset
c)
tuple