Fundamentals of Programming MCQs (Part-8)

Which of the following is a standard library in Python for mathematical functions?

A stdio
B os
C math
D file

Which of these functions is used to initialize a thread in Python’s threading module?

A start()
B run()
C execute()
D begin()

In Java, which package is used for handling I/O operations?

A java.text
B java.util
C java.io
D java.lang

What is the role of the threading module in Python?

A To manage files
B To handle exceptions
C To perform string operations
D To enable multithreading

What does the print() function in Python do?

A Prints text to the screen
B Returns output
C Reads user input
D Handles errors

Which of the following is a tool used for debugging in C?

A printf()
B log()
C debug()
D gdb

Which of these is used to create a file in Python?

A fcreate()
B open()
C file()
D newfile()

What is the default mode of opening a file in Python?

A Write mode
B Append mode
C Read mode
D Binary mode

In Java, how do you create a new thread?

A By using new Thread()
B By extending Thread
C Both A and B
D By implementing Runnable

Which of these is the correct way to handle an exception in Java?

A try {catch}
B throw (Exception e)
C catch (Exception e)
D finally (Exception e)

Which of these is a method used to stop a thread in Python?

A join()
B terminate()
C end()
D stop()

In C, which function is used to free dynamically allocated memory?

A malloc()
B free()
C alloc()
D delete()

What is the primary purpose of the Thread.sleep() method in Java?

A Create a new thread
B Resume thread execution
C Pause thread execution
D Terminate the thread

In Python, how do you import the os module?

A include os
B from os import *
C use os
D import os

In Java, how do you start a new thread using Runnable?

A Thread.start(new Runnable())
B new Runnable()
C Thread.run()
D Thread.execute(Runnable)