1. Java was developed by ____________.
a. Sun MicroSystem
b. Microsoft
c. Oracle
d. IBM
2. Who invented Java Programming?
a. Guido van Rossum
b. James Gosling
c. Dennis Ritche
d. Bjarne Stroustrup
3. Java language was initially called as
a. Sumatra
b. J++
c. Oak
d. Pine
4. JDK stands for ________________.
a. Java development kit
b. Java deployment kit
c. JavaScript deployment kit
d. None of these
5. JRE stands for _________________
a. Java run ecosystem
b. JDK runtime Environment
c. Java Runtime Environment
d. None of these
6. What is the full form of JVM?
a. Java Very Large Machine
b. Java Verified Machine
c. Java Very Small Machine
d. Java Virtual Machine
7. JAR in java stands for _______________.
a. Java Archive
b. Java application runtime
c. Java application runner
d. None of these
8. Java compiler translates Java source code into _________.
a. Java bytecode
b. machine code
c. assembly code
d. another high-level language code
9. What is byte code in Java?
a. Code generated by a Java compiler
b. Code generated by a Java Virtual Machine
c. Name of Java source code file
d. Block of code written inside a class
10. _________ is a software that interprets Java bytecode.
a. Java virtual machine
b. Java compiler
c. Java debugger
d. Java API
11. Which of the following is not a Java features?
a. Dynamic
b. Architecture Neutral
c. Use of pointers
d. Object-oriented
12. ________ is Architecture-Neutral.
a. Java
b. C++
c. C
d. Ada
13. What makes the Java platform independent?
a. Advanced programming language
b. It uses bytecode for execution
c. Class compilation
d. All of these
14. Which is the correct absolute path of a file in Java?
a. C:Program FilesJavajdk1.8.0_131binfile_name.txt
b. C:Program FilesJavafile_name.txt
c. C:Program FilesJavajdk1.8.0_131file_name.txt
d. C:Program FilesJavajdk1.8.0_131binFile Handlingfile_name.txt
15. The extension name of a Java source code file is_________.
a. .java
b. .obj
c. .class
d. .exe
16. The extension name of a Java bytecode file is_________.
a. .java
b. .obj
c. .class
d. .exe
17. What is the extension of compiled java class:
a. .txt
b. .JS
c. .class
d. .java
18. Command to compile a class in the file Test.java is________.
a. java Test
b. java Test.java
c. javac Test.java
d. javac Test
19. ________ consists of a set of separate programs for developing and testing Java programs, each of which is invoked from a command line.
a. Java language specification
b. Java API
c. Java JDK
d. Java IDE
20. Which of these components are used in a Java program for compilation, debugging, and execution?
a. JDK
b. JVM
c. JRE
d. JIT
21. ________ contains predefined classes and interfaces for developing Java programs.
a. Java language specification
b. Java API
c. Java JDK
d. Java IDE
22. ________ is a technical definition of the language that includes the syntax and semantics of the Java programming language.
a. Java language specification
b. Java API
c. Java JDK
d. Java IDE
23. Multiline comment is created using ___.
a. //
b. /* */
c. <!– — >
d. All of these
24. Every statement in Java ends with ____________.
a. a semicolon (;)
b. a comma (,)
c. a period (.)
d. an asterisk (*)
25. What is the entry point of a program in Java?
a. main() method
b. The first line of code
c. Last line of code
d. main class
26. All Java applications must have a method __________.
a. public static Main(String[] args)
b. public static Main(String args[])
c. public static void main(String[] args)
d. public void main(String[] args)
27. Which of the following are not java keywords?
a. double
b. switch
c. then
d. instanceOf
28. Which class in Java is used to take input from the user?
a. Scanner
b. Input
c. Applier
d. None of these
29. Out of these classes, which one is used for reading strings and characters in Java from the console?
a. StringReader
b. BufferedReader
c. InputStreamReader
d. BufferedStreamReader
30. Method used to take a string as input in Java?
a. next()
b. nextLine()
c. Both A. and B.
d. None of these
31. Which of the following is the correct syntax to create a variable in Java?
a. var name;
b. int name;
c. var name int;
d. All of these
32. To assign a value 1 to variable x, you write_________
a. 1 = x;
b. x = 1;
c. x := 1;
d. 1 := x;
33. In Java, after executing the following code what are the values of x, y and z? int x,y=10; z=12; x=y++ + z++;
a. x=22, y=10, z=12
b. x=24, y=10, z=12
c. x=24, y=11, z=13
d. x=22, y=11, z=13
34. _________data type requires the most amount of memory.
a. long
b. int
c. short
d. byte
35. Java supports both Primitive & Non-Primitive(User Defined) datatypes. Which one of the following is not a primitive datatype?
a. Byte
b. Short
c. Long
d. Class
36. Select the valid statement.
a. char[] ch=new char(5);
b. char[] ch= new char[5];
c. char[] ch=new char()
d. Char[]
37. Which of these is a type of variable in Java?
a. Instance Variable
b. Local Variable
c. Static Variable
d. All of these
38. A variable defined inside a method is referred to as _______.
a. a global variable
b. a method variable
c. a block variable
d. a local variable
39. What is type casting in Java?
a. It is converting type of a variable from one type to another
b. Casting variable to the class
c. Creating a new variable
d. All of these
40. The break statement in Java is used to ______________.
a. Terminates from the loop immediately
b. Terminates from the program immediately
c. Skips the current iteration
d. All of these
41. A block is enclosed inside _________________.
a. Parentheses
b. Braces
c. Brackets
d. Quotes
42. Array in java is ______________________.
a. Collection of similar elements
b. Collection of elements of different types
c. The data type of consisting of characters
d. None of these
43. Which of these operators is used to allocate memory to array in Java?
a. alloc
b. malloc
c. new malloc
d. new
44. When you invoke a method with a parameter, the value of the argument is passed to the parameter. This is referred to as ______.
a. method invocation
b. pass by value
c. pass by reference
d. pass by name
45. Arguments to methods always appear within __________.
a. brackets
b. parentheses
c. curly braces
d. quotation marks
46. Identify the return type of a method that does not return any value
a. int
b. void
c. double
d. none
47. The signature of a method consists of _______________.
a. method name
b. method name and parameter list
c. return type, method name, and parameter list
d. parameter list
48. The expression “Java ” + 1 + 2 + 3 evaluates to ________.
a. Java123
b. Java6
c. Java 123
d. java 123
49. Object in java are ____________.
a. Classes
b. References
c. Iterators
d. None of these
50. Java object oriented programming concepts is/are
a. Encapsulation
b. Inheritance
c. Polymorphism
d. All of the above.
51. Which one is a template for creating different objects?
a. An array
b. A class
c. Interface
d. Method
52. Hiding the complexity in program is known as
a. Abstraction
b. Encapsulation
c. Data hiding
d. Composition
53. Encapsulation is ____________________.
a. Wrapping up of data and related functions into a single entity
b. Creating special methods
c. Creating special data structure
d. All of these
54. Encapsulation concept in java is
a. Hiding complexity
b. method hiding
c. Hiding constructor
d. None
55. Following concept can be used for encapsulation in java programs
a. Wrapping data fields with methods
b. Hiding data and internal methods using access modifiers in a class
c. Using Interfaces
d. All of the above
56. Exposing only necessary information to clients ( main programs, classes) is known as
a. Abstraction
b. Encapsulation
c. Data hiding
d. Hiding complexity
57. Polymorphism types in Java is/are
a. Compile time
b. Run time
c. Both
d. None
58. What is polymorphism in Java?
a. Performing a single task in multiple ways
b. Performing multiple tasks using multiple methods
c. Creating a new class for each task
d. All of these
59. Which polymorphism concept is applied to inheritance relationship in java programming?
a. Method overloading
b. Constructor overloading
c. Method overriding
d. None
60. Runtime polymorphism feature in java is
a. method overriding
b. method overloading
c. constructor overloading
d. operator overloading
61. Which feature comes under compile time polymorphism?
a. Method overloading
b. Constructor overloading
c. Method overriding
d. Both a and b
62. What concepts come under Polymorphism in java?
a. Method overloading
b. Constructor overloading
c. Method overriding
d. All the above
63. Wrapper class in java is _______________.
a. Used to encapsulate primitive data types
b. Declare new classes called wrapper
c. Create a new instance of the class
d. None of these
64. ‘this’ keyword in java is _______________.
a. Used to hold the reference of the current object
b. Holds object value
c. Used to create a new instance
d. All of these
65. Which keyword is used to refer current object of a class in Java?
a. This
b. New
c. Current
d. None
66. In java, “this” keyword is used to
a. Pass as an argument to a method.
b. Refer current class object.
c. Return current class object.
d. All are correct.
67. True statement about extending a class in java is
a. A class can extends only one another class
b. A class can extends multiple classes.
c. A class can extends multiple interfaces.
d. None
68. Which statement is correct for private member in Java?
a. Access outside the class is allowed
b. Any class can access
c. Declared using private keyword
d. All of these
69. Inheritance is way to
a. Make general classes into more specific classes.
b. Pass arguments to objects of classes
c. Add features to existing classes without rewriting them.
d. Improve data-hiding and encapsulation
70. Advantages of inheritance include
a. providing class growth
b. avoiding rewriting of code
c. data abstraction
d. simulation of real-world entities
71. Java does not support _______________?
a. Inheritance
b. Multiple inheritance for classes
c. multiple inheritance of interfaces
d. compile time polymorphism
72. Which keyword is used to inherit classes in Java?
a. Extends
b. Inheritance
c. IsChild
d. None of these
73. When creating a subclass, what keyword is used to include a super class?
a. Extends
b. Static
c. This
d. implement
74. Which of the following inheritance of class is invalid in Java?
a. Single
b. Multiple
c. Multi-level
d. Hierarchical
75. Which of these are Access Modifiers in java?
a. Default
b. Public
c. Protected
d. All of these
76. Which of these is a non-access modifier?
a. Public
b. Private
c. Native
d. All of these
77. The super() method is used to __________.
a. Call constructor of friend class
b. Is a declared method
c. Call constructor of the parent class
d. Call constructor
78. The ‘super’ keyword is used to _________.
a. Access instance of the parent class
b. Access instance of the same class
c. Access instance of child class
d. Access instance of friend class
79. Super keyword in java is used to
a. refer current class object.
b. refer static method of the class.
c. refer parent class object.
d. refer static variable of the class.
80. Super keyword in java is used to
a. Refer immediate parent class instance variables.
b. Invoke immediate parent class methods.
c. Invoke immediate parent class constructor.
d. All
81. How does a subclass execute its superclass constructor?
a. static ( )
b. super( )
c. this ( )
d. extends ( )
82. Which keyword is used to declare an interface in java?
a. Class
b. Interface
c. Implements
d. Abstract
83. Which of these access specifiers can be used for an interface?
a. Public
b. Protected
c. Private
d. Any of the above
84. What is Runnable?
a. Abstract class
b. Interface
c. Class
d. Method
85. False statement about Java interface
a. It is used to achieve abstraction and multiple inheritance in Java.
b. It can be instantiated, means we can create an object of an interface.
c. There can be only abstract methods in the interface not method body.
d. All are correct.
86. Which is true statements about an interface in java?
a. An interface can extend another interface
b. We can create object of an interface in java
c. An interface can have constructor
d. None
87. Which is correct option about java interface?
a. Interface is used to achieve multiple inheritance in java
b. Object of an interface cannot be created.
c. An interface can extend another interface.
d. All of the above
88. The fields in an interface are implicitly specified as
a. Static
b. Protected
c. Private
d. Static and final
89. Which of these is true for interfaces in java?
a. The keyword interface is used to create a method
b. All the methods of an interface are abstract
c. It does not contain constructors
d. All of these
90. The ‘implements’ keyword is used to __________.
a. Implement the function of a class
b. Inherit an interface in Java
c. Inherit a class in java
d. All of these
91. A java interface can contain _________________
a. public static Final Variables only
b. public Abstract methods
c. Abstract methods(unimplemented) and implemented methods both
d. public static Final Variables and abstract methods both
92. In Java, when we implement an interface method, it must be declared as:
a. Private
b. protected
c. public
d. friend
93. A class inherits an interface using which keyword?
a. Extends
b. Implements
c. Inherit
d. None
94. Correct statement about a class and interface is/are
a. An interface can extend multiple interfaces
b. A class can implement multiple interfaces.
c. Java support multiple inheritance using interfaces.
d. All of the above.
95. Which of the following is true about methods in an interface in java?
a. An interface can contain only abstract method.
b. We can define a method in an interface
c. Private and protected access modifiers can also be used to declare methods in interface
d. None
96. Which of the following is a type of polymorphism in java programming?
a. Multiple polymorphism
b. Multilevel polymorphism
c. Compile time polymorphism
d. Execution time polymorphism
97. Which of these keywords can be used to prevent method overriding in java?
a. Final
b. Protected
c. Static
d. Constant
98. False statement about final method in java
a. Value of final variable cannot be changed once initialized.
b. Final method is inherited but we cannot override it
c. If you make a class final then you cannot extend the class
d. Constructor can be declared as final.
99. Final keyword in java is used with
a. Class
b. class fields
c. class methods
d. All of the above
100. What is the use of final keyword in Java?
a. When a class is made final, a subclass of it cannot be created
b. When a method is final, it can not be overridden.
c. When a variable is final, it can be assigned value only once.
d. All of the above
101. Which of the following can be declared as final in java?
a. Class
b. Method
c. Variable
d. All of these
102. Abstract class is _______________.
a. Created using abstract keyword
b. Contains only abstract method
c. Needs to be inherited to be used
d. All of these
103. What are packages in Java?
a. Methods of a friend class
b. Methods of the main class
c. Way to encapsulate a group of classes, sub-packages, and interface
d. All of these
104. Package in Java is a mechanism to encapsulate a ____________.
a. Classes
b. Sub Packages
c. Interfaces
d. All of the above
105. Which of these keywords is used to define packages in Java?
a. Pkg
b. Pkg
c. Package
d. Package
106. Which Java keyword is used to access features of a package?
a. Get
b. Import
c. Extends
d. All of these
107. Which of the following is the correct way of importing an entire package “pkg”?
a. import pkg.
b. Import pkg.
c. import pkg.*
d. Import pkg.*
108. Packages that are inside another package are the _________
a. Packages
b. nested packages
c. util subpackages
d. subpackages
109. Which keyword in java is used for exception handling?
a. exep
b. excepHand
c. throw
d. All of these
110. try, catch, finally, throw, and throws keywords in java are related to
a. Event handling
b. string handling
c. exception handling
d. None of the above
111. Exception created by try block is caught in which block
a. catch
b. throw
c. final
d. none
112. Finally block is attached to?
a. Try-catch block
b. Class block
c. Method block
d. All of these
113. Types of exceptions in Java programming are
a. Checked exception
b. unchecked exception
c. Both A & B
d. None
114. If an exception is thrown from try block in java program then which block handle the exception?
a. catch
b. finally
c. final
d. finalize
115. Checked exception caught at
a. compile time
b. run time
c. Both at compile and run time
d. None
116. Unchecked exception caught at
a. compile time
b. run time
c. Both at compile and run time
d. None
117. Which is the super class of all java exceptions classes?
a. Exception
b. RuntimeException
c. Throwable
d. IOException
118. Direct subclass of Throwable in Java
a. Exception
b. Error
c. Both A & C
d. None
119. un-checked(runtime) exception in java is/are
a. ArrayIndexOutOfBoundsException
b. ArithmeticException
c. NullPointerException
d. All
120. Incorrect statement(s) about finally block in java exception
a. Finally block always follow try catch block
b. finally block always executes whether exception is handled or not.
c. There can be multiple finally blocks followed by try catch block.
d. All are correct
121. True statement(s) about try catch block
a. It is mandatory to have catch block with every try block
b. There must be only one catch block followed by try block
c. There can be multiple catch block followed by try block.
d. All
122. When a finally block executed in Java?
a. Try block is executed without any exception
b. Exception has occurred
c. Executed at last
d. None of these
123. Which of these is a super class of all errors and exceptions in the Java language?
a. RunTimeExceptions
b. Throwable
c. Catchable
d. None of the above
124. Which is not an exception in Java?
a. IO Exception
b. Logical Exception
c. Array Index out of bound Exception
d. Arithmetic Exception
125. Which keyword is used to specify the exception thrown by method?
a. catch
b. throws
c. finally
d. throw
126. Which of the following blocks execute compulsorily whether exception is caught or not.
a. finally
b. catch
c. throws
d. throw
127. Which of the following example is unchecked exception?
a. IO Exception
b. ClassNotFoundException
c. NumberException
d. NullPointerException
128. The built-in base class in Java, which is used to handle all exceptions is
a. Raise
b. Exception
c. Error
d. Throwable
129. In java a thread can be created by
a. Extending the thread class
b. Implementing Runnable interface
c. Both of the above
d. None of these
130. When a class extends the thread class, it should override _____ method of Thread class to start that thread.
a. start()
b. run()
c. init()
d. go()
131. Which of these is a property of threads in Java?
a. Multiple threads can be executed concurrently
b. Has its own priority
c. Both A. and B.
d. None of these
132. Multithreading in java is ____________.
a. Executing multiple processes simultaneously
b. Creating more threads at a time
c. Blocking threads
d. All of these
133. How many threads can be executed at a time?
a. Only one thread
b. Multiple threads
c. Only main (main() method) thread
d. Two threads
134. Java uses threads to enable the entire environment to be ______.
a. Symmetric
b. Asymmetric
c. Synchronous
d. Asynchronous
135. Java ___________ can run from a Web browser.
a. Applications
b. applets
c. servlets
d. Micro Edition programs
136. Which one of the following is correct?
a. Java applets can not be written in any programming language
b. An applet is not a small program
c. An applet can be run on its own
d. Applets are embedded in another applications