MCQ Questions on Java With Answers for BCA, MCA And Gate Exam
1. Which of the following options leads to the portability and security of Java?
- Bytecode is executed by JVM
- The applet makes the Java code secure and portable
- Use of exception handling
- Dynamic binding between objects
2. Which of the following is not a Java feature?
- Dynamic
- Architecture Neutral
- Use of pointers
- Object-oriented
3. ____ is used to find and fix bugs in the Java programs.
- JVM
- JRE
- JDK
- JDB
4. The earlier name of Java was ___________________.
- OAK
- OOAK
- JDK
- None
5. ________________ is the first graphical browser.
- IE
- Mosaic
- Chrome
- None
6. What is the Java command to disassemble Java files and print the representation of Java bytecode?
- javap
- javac
- javadoc
- jar
7. _______________ is used to create and manage public keys, private keys, and security certificates.
- ab tools
- Key tools
- both
- none
8. On which platforms does Java run?
- Windows
- Unix
- Mac
- All
9. Which is not a Java Platform?
- NetBeans
- IntelliJ
- Visual studio code
- Eclipse
10. What is bytecode in Java?
- Code generated by Java
- Code generated by JVM
- Name of Java source file
- Block of code
11. The JAVA program converted into an intermediate language representation by a compiler is called __________________.
- Byte code
- machine code
- binary code
- Compile code
12. The concept of __________________ is possible in Java.
- Write once
- Write once and run anywhere
- both
- none
13. ___________________ is the extension for Java source code files.
- .javadoc
- .javac
- .java
- none
14. The code in the Java programming language is put inside ___________.
- Blocks
- Methods
- Classes, Interfaces
- All the above
15. In Java, the word ________ is used to create a new object.
- java
- new
- class
- function
16. In Java, an object is created at _________ time.
- Assembling time
- Run time
- Compile-time
- None of the above
17. A _________________ access specifier allows the method to be executed from another class.
- Private
- Public
- Protected
- None
18. Java program processing always starts with the main() method.
- TRUE
- FALSE
- 0
- 0
19. Java is a case-sensitive language.
- FALSE
- TRUE
- 0
- 0
20. _________________ command is used to compile the Java source code.
- .Javac
- .java
- .javadoc
- none
21. Which one of the following is an Equality operator in Java?
- <=
- =
- !=
- none
22. Which one of the following is a Unary operator in Java?
- ()
- ++
- *
- =
23. Which of the following operators has more precedence?
- ()
- =
- ++
- --
24. Which of the following is not an operator in Java?
- !
- ^
- ~
- <->
25. Which of the following operators has more precedence in Java?
- *
- +
- -
- none
26. The __________ selects among a set of statements depending on the value of a controlling expression.
- If
- for
- while
- none
27. An IF statement in Java is also a _______ statement.
- Number
- conditional
- String
- None of the above
28. Select the proper Java IF statement syntax from the list below.
- if(condition) //statement
- if(condition){ //statement}
- if(condition){ //statement1 //statement2}
- All of the above
29. In Java, the keyword used to declare a class is _________.
- Function
- Methods
- Class
- Java
30. A Java class can contain___________.
- Variables
- Methods, Constructors
- Inner Classes (A class inside another class)
- All of the above
31. Which of these methods of the String class is used to obtain a character at a specified index?
- char()
- Charat()
- charat()
- charAt()
32. A String in Java is a?
- Class
- Object
- Variable
- Character of array
33. Which of these methods of the String class can be used to test two strings for equality?
- isequal()
- isequals()
- equal()
- equals()
34. Which of the following statements is incorrect?
- String is a class
- Strings in Java are mutable
- Every string is an object of class String
- Java defines a peer class of String, called StringBuffer, which allows strings to be altered
35. _________ are a sequence of characters.
- Character
- Strings
- Integers
- Classes
36. The String class is?
- Mutable
- Immutable
- a & b
- none
37. How do you declare an array in Java?
- int[] arr;
- int arr[];
- int arr;
- Array<int> arr;
38. How do you access an element in an array in Java?
- By using the element's value
- By using the element's index
- By using the element's key
- By using the element's label
39. Which method is used to copy one array into another in Java?
- copy()
- clone()
- System.arraycopy()
- Arrays.copy()
40. What symbol is used for a variable method parameter?
- ..
- **
- __
- ...
41. What are the features of Object Oriented Programming (OOPs)?
- Inheritance
- Encapsulation
- Polymorphism
- All of the above
42. The class that is being inherited or subclassed is called ___.
- Subclass
- Superclass
- 0
- Superset
43. Java language supports ___ type of inheritance.
- Multiple Inheritance
- Multi-Level Inheritance
- 0
- 0
44. Which is the keyword used to implement inheritance in Java?
- extends
- implements
- instanceof
- None
45. Which of these keywords is used to define packages in Java?
- pkg
- Pkg
- package
- Package
46. Which access specifiers can be used for a class so that its members can be accessed by a different class in the same package?
- Public
- Private
- Protected
- All of the above
47. Packages that are inside another package are the _________.
- packages
- nested packages
- util subpackages
- subpackages
48. Which of these keywords is used to define interfaces in Java?
- interface
- Interface
- into
- Intf
49. Which of these keywords is used by a class to use an interface defined previously?
- import
- Import
- implements
- Implements
50. Which of these access specifiers can be used for an interface?
- Public
- Protected
- private
- All of the above
51. When does Exceptions in Java arise in the code sequence?
- Run Time
- Compilation Time
- Can Occur Any Time
- None of the mentioned
52. Which of these keywords is not a part of exception handling?
- try
- finally
- thrown
- catch
53. Which of these keywords is used to manually throw an exception?
- try
- finally
- throw
- catch
54. Which of these is a super class of all errors and exceptions in the Java language?
- Catchable
- Throwable
- RunTimeExceptions
- None of the above
55. In which of the following package does the Exception class exist?
- java.file
- java.lang
- java.io
- java.util
56. Which exception is thrown when a divide by zero statement executes?
- NumberFormatException
- NullPointerException
- ArithmeticException
- None of these
57. Which of these classes is related to all the exceptions that can be caught by using catch?
- Error
- Exception
- RuntimeException
- All of the mentioned
58. Which of these handles the exception when no catch is used?
- Default handler
- finally
- throw handler
- Java runtime system
59. Which of these keywords is used by the calling function to guard against the exception thrown by the called function?
- try
- throw
- throws
- catch
60. Which exceptions will occur if we try to access the index of an array beyond its length?
- ArithmeticException
- ArrayException
- ArrayIndexException
- ArrayIndexOutOfBoundsException
61. Which of these streams contains the classes which can work on character streams?
- InputStream
- OutputStream
- Character Stream
- All of the mentioned
62. Which of these classes is used to read characters in a file?
- FileReader
- FileWriter
- FileInputStream
- InputStreamReader
63. Which of these methods of the FileReader class is used to read characters from a file?
- read()
- scanf()
- get()
- getInteger()
64. Which of these classes can be used to implement the input stream that uses a character array as the source?
- BufferedReader
- FileReader
- CharArrayReader
- FileArrayReader
65. Which of these classes can return more than one character to be returned to the input stream?
- BufferedReader
- BufferedWriter
- PushbackReader
- CharArrayReader
66. How many methods are there in a functional interface in Java 8?
- 0
- 1
- 2
- 3
67. What is the Stream API in Java 8?
- A new file I/O stream library
- A new concurrency library
- A new API for working with collections
- A new API for working with databases
68. A Lambda expression returns
- Object
- Nothing
- Function
- Reference
69. What is not true about functional interfaces in Java?
- They contain only one abstract method.
- They exhibit only one functionality.
- Runnable and Callable are not examples of functional interfaces.
- None
70. Which of these does the Stream map() operate on?
- Class
- Interface
- Predicate
- Function