Hey Guys welcome to CES Study247
This page provide you Java programming Multiple Choice Question Answer that is very useful for Semester , DRDO, ISRO ,Banking , Railway, Gate and another exam.
Q.21 In Java, the System class is defined in which package?
java.util package
java.io package
java.lang package
None of these
Explanation
The java.lang package is automatically imported into every Java program and contains fundamental classes like System, String, and Math.
Q.22 Which of the following is NOT a feature of the Java programming language?
Use of pointers
Dynamic
Object-oriented
None of these
Explanation
Java does not support direct use of pointers to ensure memory safety and security, unlike languages like C or C++.
Q.23 In Java, the Scanner class is defined in which package?
java.util package
java.lang package
java.io package
None of these
Explanation
The Scanner class, used for obtaining user input, is part of the java.util utility package.
Q.24 A variable that is declared inside a method is known as a?
Static variable
Local variable
Instance variable
None of these
Explanation
Local variables are defined within a method or block and are only accessible within that specific scope.
Q.25 What is the primary reason for Java's portability and security?
Bytecode
Dynamic
Exception handling
None of these
Explanation
Java source code is compiled into platform-independent Bytecode (.class files), which can be executed on any machine with a Java Virtual Machine (JVM).
Q.26 Which of the following is NOT an access modifier in Java?
Void
Public
Private
None of these
Explanation
void’ is a keyword that specifies a method does not return a value; it is not an access modifier like public, private, or protected.
Q.27 In Java, the Scanner class is primarily used to take user input at?
Run-time
Compile time
Both A & B
None of these
Explanation
The Scanner class allows programs to interact with the user and accept data while the program is actively running.
Q.28 Which standard stream is used in Java for receiving input?
System.in
System.out
Both A & B
None of these
Explanation
System.in is the standard input stream, typically representing input from the keyboard.
Q.29 Which standard stream is used in Java for sending output?
System.in
System.out
Both A & B
None of these
Explanation
System.out is the standard output stream, typically used to display text on the computer console.
Q.30 Which keyword is used to access the features (classes/interfaces) of another package?
package
Scanner
import
None of these
Explanation
The ‘import’ keyword allows you to use classes from different packages without using their fully qualified names.
Q.31 Which Scanner class method is specifically used to read an integer value from the user?
next()
nextInt()
readInt()
None of these
Explanation
The nextInt() method scans the next token of the input as an int.
Q.32 How many primary categories of data types exist in Java?
1
2
3
None of these
Explanation
Java data types are divided into two main categories: Primitive data types (e.g., int, char) and Non-Primitive (Reference) data types (e.g., String, Array).
Q.33 Which of the following is NOT a core Object-Oriented Programming (OOP) concept?
Inheritance
Encapsulation
Polymorphism
Compilation
Explanation
The four pillars of OOP are Abstraction, Encapsulation, Inheritance, and Polymorphism. Compilation is a process, not a concept.
Q.34 The process that focuses only on the essential characteristics of an object while hiding details is:
Encapsulation
Polymorphism
Abstraction
Inheritance
Explanation
Abstraction is the concept of describing an object in terms of its essential properties and behaviors relative to the problem being solved.
Q.35 In object-oriented programming, 'Composition' refers to:
The use of consistent coding conventions
Coherent, common behavior within objects
Procedural behavior
None of these
Explanation
Composition represents a ‘has-a’ relationship between classes, promoting coherent and reusable behavior.
Q.36 Which of the following is generally NOT considered a modern integrated development environment (IDE)?
NetBeans
Borland's JBuilder
MS J++
Symantec Visual Cafe
Explanation
While historically significant, Symantec Visual Cafe is an older tool and often excluded from modern lists of standard Java IDEs.
Q.37 Which of the following is an incorrect name for a Java identifier (variable)?
xyz
2nd name
xy2z
xyz2
Explanation
Java identifiers cannot begin with a digit. They must start with a letter, underscore (_), or dollar sign ($).
Q.38 The Java compiler (javac) translates source code (.java) into which format?
Assembly language
Bytecode
Bit code
Machine code
Explanation
The compiler produces Bytecode (.class files), which is then interpreted or JIT-compiled by the JVM.
Q.39 In the context of 'Polymorphism', the Greek word 'poly' means?
One
Many
Two
None of these
Explanation
Polymorphism literally means ‘many forms’. It allows objects of different types to be treated as objects of a common base type.
Q.40 In which year was the first conceptual version/implementation of the JVM introduced?
1998
1976
1994
None of these
Explanation
The Java technology, including early versions of the JVM, was initially developed by Sun Microsystems in the mid-90s, around 1994-1995.