Home Programming Kids Programming Hardware & Software Hardware & Networking APP security Software Education Kids Study MCQS Download OTHERS Festivals Multiple Choice Question (MCQ) Multiple Choice Question (MCQ) Login

Java Basic Multiple Choice Question MCQ

Categories: Programming

Ques. 1) Which of the following option leads to the portability and security of Java?


a) Bytecode is executed by JVM

b) The applet makes the Java code secure and portable

c) Use of exception handling

d) Dynamic binding between objects

Answer: (a) Bytecode is executed by the JVM.


Ques. 2) Which of the following is not a Java features?


a) Dynamic

b) Architecture Neutral

c) Use of pointers

d) Object-oriented

Answer: (c) Use of pointers


Ques. 3) The \u0021 article referred to as a


a) Unicode escape sequence

b) Octal escape

c) Hexadecimal

d) Line feed

Answer: (a) Unicode escape sequence


Ques. 4) _____ is used to find and fix bugs in the Java programs.


a) JVM

b) JRE

c) JDK

d) JDB

Answer: (d) JDB


Ques. 5) Which of the following is a valid declaration of a char?


a) char ch = '\utea';

b) char ca = 'tea';

c) char cr = \u0223;

d) char cc = '\itea';

Answer: (a) char ch = '\utea';


Ques. 6) What is the return type of the hashCode() method in the Object class?


a) Object

b) int

c) long

d) void

Answer: (b) int


Ques. 7) Which of the following is a valid long literal?


a) ABH8097

b) L990023

c) 904423

d) 0xnf029L

Answer: (d) 0xnf029L


Ques. 8) What does the expression float a = 35 / 0 return?


a) 0

b) Not a Number

c) Infinity

d) Run time exception

Answer: (c) Infinity


Ques. 9) Evaluate the following Java expression, if x=3, y=5, and z=10:


++z + y - y + z + x++

a) 24

b) 23

c) 20

d) 25

Answer: (d) 25


Ques. 10) What will be the output of the following program?


public class Test {  

public static void main(String[] args) {  

    int count = 1;  

    while (count <= 15) {  

    System.out.println(count % 2 == 1 ? "***" : "+++++");  

    ++count;  

        }      // end while  

    }       // end main   

 }  

a) 15 times ***

b) 15 times +++++

c) 8 times *** and 7 times +++++

d) Both will print only once

Answer: (c) 8 times *** and 7 times +++++


Ques. 11) Which of the following tool is used to generate API documentation in HTML format from doc comments in source code?


a) javap tool

b) javaw command

c) Javadoc tool

d) javah command

Answer: (c) Javadoc tool


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


a) new List(false, 3)

b) new List(3, true)

c) new List(true, 3)

d) new List(3, false)

Answer: (b) new List(3, true)


Ques. 13) Which of the following for loop declaration is not valid?


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

b) for ( int i = 7; i <= 77; i += 7 )

c) for ( int i = 20; i >= 2; - -i )

d) for ( int i = 2; i <= 20; i = 2* i )

Answer: (a) for ( int i = 99; i>=0; i / 9)


Ques. 14) Which method of the Class.class is used to determine the name of a class represented by the class object as a String?

a) getClass()

b) intern()

c) getName()

d) toString()

Answer: (c) getName()


Ques. 15) In which process, a local variable has the same name as one of the instance variables?


a) Serialization

b) Variable Shadowing

c) Abstraction

d) Multi-threading

Answer: (b) Variable Shadowing


Ques. 16) Which of the following is true about the anonymous inner class?


a) It has only methods

b) Objects can't be created

c) It has a fixed class name

d) It has no class name

Answer: (d) It has no class name


Ques. 17) Which package contains the Random class?

a) java.util package

b) java.lang package

c) java.awt package

d) java.io package

Answer: (a) java.util package


Ques. 18) What do you mean by nameless objects?


a) An object created by using the new keyword.

b) An object of a superclass created in the subclass.

c) An object without having any name but having a reference.

d) An object that has no reference.

Answer: (d) An object that has no reference.


Ques. 19) An interface with no fields or methods is known as a ______.


a) Runnable Interface

b) Marker Interface

c) Abstract Interface

d) Char Sequence Interface

Answer: (b) Marker Interface


Ques. 20) Which of the following is an immediate subclass of the Panel class?


a) Applet class

b) Window class

c) Frame class

d) Dialog class

Answer: (a) Applet class


Top articles
Let’s know about C++ Variables, Literals and Constants Published at:- Why is C called a mid-level programming language? Published at:- What is the Best Programming language in 2023 Published at:- Top Devices for Programmers in 2023 Published at:- Ultimate Guide to Choosing a Programming Laptop Published at:- Turbo c++ online compiler download Published at:- Online c++ compiler for mobile phone Published at:- Python site drive google com Published at:- Python programming for beginners Published at:- Microsoft 365 developer program Published at:- javascript code online Test Published at:- Object-Oriented Programming (OOP) concepts in java Published at:- Object-Oriented Programming (OOP) concepts in python Published at:- Features of object oriented programming Published at:- 10 Tips for Optimizing Java Compilers Published at:- 10 Reasons to Choose an Online Java Compiler Published at:- 10 Reasons to Choose an Online C++ Compiler Published at:- What Are the Benefits of Using an Online C++ Compiler Published at:- Java Basic Multiple Choice Question MCQ Published at:-

Java Basic Multiple Choice Question MCQ