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