Explore topic-wise MCQs in Python.

This section includes 39 Mcqs, each offering curated multiple-choice questions to sharpen your Python knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the output of the below Java program using toString() method?

A. Printing Object=
B. Printing Object=null
C. Printing Object=College Object
D. Compiler error
Answer» D. Compiler error
2.

State TRUE of FALSE. Java objects have built-in methods to handle threads.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
3.

___ is the superclass to all Java classes either user-defined or built-in.

A. Class
B. Object
C. Superclass
D. Null
Answer» C. Superclass
4.

A Java reference is comparable to ___ in C language.

A. Enum
B. Structure
C. Pointer
D. None
Answer» D. None
5.

In Java Pass by reference ___ is passed even if you are passing a reference to an object.

A. Address value
B. Variable value
C. Hash code
D. None of the above
Answer» B. Variable value
6.

Java object passing from one method to another method happens by ___.

A. Pass by Value
B. Pass by Reference
C. -
D. -
Answer» C. -
7.

Java object assignment happens by ___.

A. Pass by Value
B. Pass by Reference
C. -
D. -
Answer» C. -
8.

What is the output of the below Java program that passes primitive values?

A. Rats Before = 5
B. Rats Before = 20
C. Rats Before = 5
D. Rats Before = 20
Answer» B. Rats Before = 20
9.

What is the output of the below Java program that passes an object to another method?

A. Items Before = 10
B. Items Before = 5
C. Items Before = 5
D. Items Before = 10
Answer» D. Items Before = 10
10.

An object or a primitive value that is received in a method from another method is called ___ in Java. (Argument / Parameter)

A. Argument
B. Parameter
C. -
D. -
Answer» B. Parameter
11.

An object or primitive value that is passed from one method to another method is called ___ in Java. (Argument / Parameter)

A. Argument
B. Parameter
C. -
D. -
Answer» C. -
12.

A primitive variable is passed from one method to another method by ___ in Java.

A. Pass by value
B. Pass by reference
C. -
D. -
Answer» B. Pass by reference
13.

The value of one primitive variable is assigned to another primitive variable by ___ in Java.

A. Pass by value
B. Pass by reference
C. -
D. -
Answer» B. Pass by reference
14.

What is the output of the below java class?

A. T1 before: 4
B. T1 before: 2
C. T1 before: 2
D. Compiler error
Answer» D. Compiler error
15.

State TRUE or FALSE.

A. TRUE
B. FALSE
C. -
D. -
Answer» B. FALSE
16.

What is the output of the below Java program with two classes?

A. Hello Boss.!
B. No Output
C. Compiler error
D. None of the above
Answer» D. None of the above
17.

Choose the correct way of creating an object of the below class.

A. Table t = new Table;
B. Table t = new Table();
C. Table() t = new Table();
D. None of the above
Answer» C. Table() t = new Table();
18.

Choose the correct syntax for declaring a Java class below.

A. class CLASSNAME
B. CLASSNAME class
C. class CLASSNAME;
D. Class CLASSNAME
Answer» B. CLASSNAME class
19.

Choose the correct statement about Java main method.

A. The main method is not a required method
B. The main method must be declared public static void.
C. you can define program flow using the main method. The Java virtual machine calls the main method directly.
D. All the above
Answer» E.
20.

An object is created at __ time in Java.

A. Compile-time
B. Run time
C. Assembling time
D. None of the above
Answer» C. Assembling time
21.

Choose the correct statements about choosing a name for a class in Java.

A. The class name can start with only a letter or underscore or dollar sign.
B. The class name can contain numbers
C. The class name can not start with a number
D. All the above
Answer» E.
22.

The keyword used to create a new object in Java is ___.

A. class
B. java
C. new
D. create
Answer» D. create
23.

Creating an object from a class is also called ____.

A. Initializing
B. Instantiating
C. Interfacing
D. None of the above
Answer» C. Interfacing
24.

How many maximum numbers of objects can be created from a single Class in Java?

A. 32
B. 64
C. 256
D. None
Answer» E.
25.

A Java class can contain___.

A. Variables
B. Methods, Constructors
C. Inner Classes (A class inside another class)
D. All the above
Answer» E.
26.

In Java, the keyword used to declare a class is ___.

A. Class
B. Java
C. class
D. java
Answer» D. java
27.

In a .java file, how many numbers of public types namely class, interface or abstract can be managed?

A. 1
B. 2
C. 3
D. Any number
Answer» B. 2
28.

State TRUE or FALSE. In Java, a public class or abstract-class or interface must be kept in a separate .java file.

A. FALSE
B. TRUE
C. -
D. -
Answer» C. -
29.

After compilation, an Interface or Abstract-Class is kept in a ___ file in Java programming.

A. .java
B. .cls
C. .class
D. .interface
Answer» D. .interface
30.

State TRUE or FALSE.

A. FALSE
B. TRUE
C. -
D. -
Answer» C. -
31.

Which is the file extension used for a compiled Java class file?

A. .j
B. .java
C. .class
D. .cls
Answer» D. .cls
32.

Which is the file extension used for a public Java class source code?

A. .j
B. .class
C. .java
D. None
Answer» D. None
33.

A Class in Java is like a ____.

A. Prototype
B. Instruction Sheet
C. Blueprint
D. All the above
Answer» E.
34.

Properties are implemented using ___ in Java.

A. Methods
B. Variables
C. Interfaces
D. All the above
Answer» C. Interfaces
35.

In Java programming language, the code is placed inside ___.

A. Classes, Interfaces
B. Methods
C. Blocks
D. All the above
Answer» E.
36.

Java is a ___ programming language.

A. Functional
B. Object-Oriented
C. Theoretical
D. All the above
Answer» C. Theoretical
37.

What is setattr() used for?

A. To access the attribute of the object
B. To set an attribute
C. To check if an attribute exists or not
D. To delete an attribute
Answer» B. To set an attribute
38.

The program has an error because constructor can’t have default arguments$

A. Nothing is displayed
B. “Hello World” is displayed
C. The program has an error display function doesn’t have parameters
Answer» C. The program has an error display function doesn‚Äö√Ñ√∂‚àö√ë‚àö¬•t have parameters
39.

_____ is used to create an object.

A. class
B. constructor
C. User-defined functions
D. In-built functions
Answer» C. User-defined functions