Quiznetik
Java Programming | Set 1
1. Who is considered as the creator of JAVA ?
A. Dennis Richie
B. Ken Thompson
C. James Gosling
D. Bjarne Stroupstrup
Correct : C. James Gosling
2. Which of the following statements about the Java language is true?
A. Java supports only Procedural Oriented Programming approach
B. Both Procedural and Object Oriented Programming are supported in Java
C. Java supports only Object Oriented Programming approach
D. None of the Above
Correct : C. Java supports only Object Oriented Programming approach
3. JRE stands for
A. Java Realtime Environment
B. Java Rapid Enterprise
C. Java Runtime Environment
D. None of the above
Correct : C. Java Runtime Environment
4. Java source files are compiled and converted to
A. Object code
B. machine code
C. Bytecode
D. executable file
Correct : C. Bytecode
5. JVM is ___________for bytecode.
A. a compiler
B. an interpreter
C. assembler
D. none of the above
Correct : B. an interpreter
6. What is the size of int data type in java?
A. 1 bytes
B. 2 bytes
C. 4 bytes
D. 8 bytes
Correct : C. 4 bytes
7. Which is a valid float literal?
A. 1.23
B. 2
C. 1.23d
D. 1.23f
Correct : D. 1.23f
8. What is the numerical range of a char in Java?
A. -128 to 127
B. 0 to 256
C. 0 to 32767
D. 0 to 65535
Correct : D. 0 to 65535
9. Which of these coding types is used for data type char in Java?
A. ASCII
B. ISO-LATIN-1
C. UNICODE
D. None of the mentioned
Correct : C. UNICODE
10. Which of these values can a boolean variable contain?
A. True & False
B. 0 & 1
C. Any integer value.
D. Both a & b
Correct : A. True & False
11. Which one of the following is a valid identifier in java?
A. x1
B. 1x
C. $x
D. x 1
Correct : A. x1
12. Which operator is used to implement unsigned right shift of an integer?
A. <<
B. >>
C. <<<
D. >>>
Correct : D. >>>
13. Which one of the following is a jump statement in java?
A. goto
B. jump
C. break
D. if
Correct : C. break
14. Which of these operators is used to allocate memory to array variable in Java?
A. malloc
B. alloc
C. new
D. new malloc
Correct : C. new
15. Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?
A. do-while
B. while
C. for
D. None of the mentioned
Correct : A. do-while
16. Which of these is necessary condition for automatic type conversion in Java?
A. The destination type is smaller than source type.
B. The destination type is larger than source type.
C. The destination type can be larger or smaller than source type.
D. None of the mentioned
Correct : B. The destination type is larger than source type.
17. What is the error in this code? byte b = 50; b = b * 50;
A. b can not store the result 2500, limited by its range.
B. * operator has converted b * 50 into int, which can not be converted to byte without casting.
C. b can not contain value 50.
D. No error in this code
Correct : B. * operator has converted b * 50 into int, which can not be converted to byte without casting.
18. Which of these is an incorrect array declaration?
A. int arr[] = new int[5];
B. int [] arr = new int[5];
C. int arr[]; arr = new int[5];
D. int arr[] = int [5] new
Correct : D. int arr[] = int [5] new
19. Which of these selection statements test only for equality?
A. if
B. switch
C. Both a & b
D. None of the mentioned
Correct : B. switch
20. Which of these are selection statements in Java?
A. if
B. for
C. continue
D. all of these
Correct : A. if
21. Which of these jump statements can skip processing remainder of code in its body for a particular iteration?
A. break
B. return
C. exit
D. continue
Correct : D. continue
22. What is the value of the expression 2 & 3 ?
A. 2
B. 3
C. 6
D. 5
Correct : A. 2
23. What is the value of the expression 8 << 2 ?
A. 2
B. 32
C. 1 6
D. 5
Correct : B. 32
24. The keyword used to create a constant variable
A. const
B. static
C. final
D. none of these
Correct : C. final
25. What is stored in the object obj in following lines of code? box obj;
A. Memory address of allocated memory of object.
B. NULL
C. Any arbitrary pointer
D. Garbage
Correct : B. NULL
26. Which of the following is a valid declaration of an object of class Box?
A. Box obj = new Box();
B. Box obj = new Box;
C. obj = new Box();
D. new Box obj;
Correct : A. Box obj = new Box();
27. Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class.
A. static
B. final
C. abstract
D. public
Correct : A. static
28. Variables declared with in a class are called
A. Identifier
B. local variable
C. instance variable
D. global variable
Correct : C. instance variable
29. Variables declared within a method or block are called
A. Static variable
B. local variable
C. instance variable
D. global variable
Correct : B. local variable
30. Defining methods with same name and different no. of parameters are called
A. Method overriding
B. method overloading
C. Dynamic method dispatch
D. none of the above
Correct : B. method overloading
31. _________ is used to initialize objects.
A. Methods
B. arguments
C. constructors
D. new keyword
Correct : C. constructors
32. What is the return type of Constructors?
A. int
B. float
C. void
D. None of the mentioned
Correct : D. None of the mentioned
33. Which of the following is a method having same name as that of its class?
A. finalize
B. delete
C. class
D. constructor
Correct : D. constructor
34. Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?
A. delete
B. free
C. new
D. None of the mentione
Correct : D. None of the mentione
35. Which of these access specifiers must be used for main() method?
A. private
B. public
C. protected
D. None of the mentioned
Correct : B. public
36. Which of these is used to access member of class before object of that class is created?
A. public
B. private
C. static
D. protected
Correct : C. static
37. The keyword used to create an object
A. class
B. this
C. new
D. malloc
Correct : C. new
38. The keyword used to refer the current object
A. class
B. this
C. new
D. malloc
Correct : B. this
39. The method which is automatically invoked during garbage collection.
A. destructor
B. terminate()
C. finalize()
D. destroy()
Correct : C. finalize()
40. Which class cannot have a subclass in java
A. abstract class
B. parent class
C. final class
D. None of above
Correct : C. final class
41. Which is the keyword used to inherit a class to another?
A. Inherits
B. extends
C. implements
D. import
Correct : B. extends
42. The use of final keyword with method definition
A. Supports method overriding
B. implements dynamic method dispatch
C. Prevents method overriding
D. none of these
Correct : C. Prevents method overriding
43. Identify the type of inheritance when two or more subclasses inherit the properties of a super class.
A. Multiple inheritance
B. Single inheritance
C. Multilevel inheritance
D. Hierarchical inheritance
Correct : D. Hierarchical inheritance
44. The keyword used inside a class to refer to its immediate super class is
A. super
B. parent
C. base
D. none of these
Correct : A. super
45. Which of the following is true in the case of abstract class
A. Abstract constructors cannot be created.
B. Abstract classes can not be inherited.
C. An abstract class contains only abstract methods.
D. All of the above.
Correct : A. Abstract constructors cannot be created.
46. Which of these keywords are used to define an abstract class?
A. abst
B. abstract
C. Abstract
D. abstract class
Correct : B. abstract
47. If a class inheriting an abstract class does not define all of its function then it will be known as?
A. abstract
B. A simple class
C. Static class
D. None of the mentioned
Correct : A. abstract
48. Which of these is not a correct statement?
A. Every class containing abstract method must be declared abstract.
B. Abstract class defines only the structure of the class not its implementation.
C. Abstract class can be initiated by new operator.
D. Abstract class can be inherited.
Correct : C. Abstract class can be initiated by new operator.
49. Which method defined in Integer class can be used to convert a whole number in string type to primitive int type.
A. valueOf()
B. intValue()
C. parseInt()
D. getInteger()
Correct : C. parseInt()
50. The method sqrt() is defined in the class
A. System
B. Root
C. Math
D. Arithmetic
Correct : C. Math
51. A primitive data type can be passed as an argument into a method
A. By value
B. by reference
C. both a & b
D. none of these
Correct : A. By value
52. Which of these is used as default for a member of a class if no access specifier is used for it?
A. private
B. public
C. public, within its own package
D. protected
Correct : C. public, within its own package
53. Which of these keywords is used to refer to member of base class from a sub class?
A. upper
B. super
C. this
D. None of the mentioned
Correct : B. super
54. Which of these is correct way of inheriting class A by class B?
A. class B + class A {}
B. class B inherits class A {}
C. class B extends A {}
D. class B extends class A {}
Correct : C. class B extends A {}
55. Which of the following are true about interfaces.
A. Methods declared in interfaces are implicitly private.
B. Variables declared in interfaces are implicitly public, static, and final.
C. An interface contains any number of method definitions.
D. The keyword implements indicate that an interface inherits from another.
Correct : B. Variables declared in interfaces are implicitly public, static, and final.
56. Which of these keywords is used to define interfaces in Java?
A. interface
B. Interface
C. intf
D. implements
Correct : A. interface
57. Which of these can be used to fully abstract a class from its implementation?
A. Objects
B. Packages
C. Interfaces
D. None of the Mentione
Correct : C. Interfaces
58. Which of these access specifiers can be used for an interface?
A. Public
B. Protected
C. private
D. All of the mentioned
Correct : A. Public
59. Which of these keywords is used by a class to use an interface defined previously?
A. import
B. Import
C. implements
D. Implements
Correct : C. implements
60. Which of the following is correct way of implementing an interface salary by class manager?
A. class Manager extends salary {}
B. class Manager implements salary {}
C. class Manager imports salary {}
D. None of the mentioned
Correct : B. class Manager implements salary {}
61. The keyword used to create a package is
A. import
B. package
C. classpath
D. public
Correct : B. package
62. The modifier which specifies that the member can only be accessed in its own class is
A. public
B. private
C. protected
D. none
Correct : B. private
63. Which of the following package stores all the standard java classes? a) jav
A. lang
B. java
C. java.util
D. java.packages
Correct : A. lang
64. Which of these is a mechanism for naming and visibility control of a class and its content?
A. Object
B. Packages
C. Interfaces
D. None of the Mentioned
Correct : B. Packages
65. Which of this access specifies can be used for a class so that its objects can be created by a different class in another package?
A. Public
B. Protected
C. No Modifier
D. All of the mentioned
Correct : A. Public
66. Which of the following is correct way of importing an entire package ‘pkg’?
A. import pkg.
B. Import pkg.
C. import pkg.*
D. Import pkg.*
Correct : C. import pkg.*
67. Which of the following is incorrect statement about packages?
A. Package defines a namespace in which classes are stored.
B. A package can contain other package within it.
C. Java uses file system directories to store packages.
D. A package can be renamed without renaming the directory in which the classes are stored.
Correct : D. A package can be renamed without renaming the directory in which the classes are stored.
68. Which of these method of class String is used to extract a single character from a String object?
A. CHARAT()
B. chatat()
C. charAt()
D. ChatAt()
Correct : C. charAt()
69. Which of these method of class String is used to obtain length of String object?
A. get()
B. Sizeof()
C. lengthof()
D. length()
Correct : D. length()
70. Which of these keywords is not a part of exception handling?
A. try
B. finally
C. thrown
D. catch
Correct : C. thrown
71. The code within the ----------- block will always be executed whether or not an exception is thrown.
A. try..catch
B. finally
C. throw
D. throws
Correct : B. finally
72. Which of these keywords must be used to monitor for exceptions?
A. try..catch
B. finally
C. throw
D. throws
Correct : A. try..catch
73. Which of these keywords is used to manually throw an exception?
A. try
B. finally
C. throw
D. catch
Correct : C. throw
74. Which of these classes is related to all the exceptions that can be caught by using catch?
A. Error
B. Exception
C. None of these
D. a & b
Correct : B. Exception
75. Which of these classes is related to all the exceptions that cannot be caught?
A. Error
B. Exception
C. None of these
D. a & b
Correct : A. Error
76. Which exception is thrown by read() method?
A. IOException
B. InterruptedException
C. SystemException
D. SystemInputException
Correct : A. IOException
77. Which is the super class of all exception classes
A. Exception
B. Object
C. Error
D. Throwable
Correct : D. Throwable
78. Which class is the super class of all classes of the java.lang package?
A. Object
B. System
C. Super
D. Class
Correct : A. Object
79. Which of the following exception is raised when a number is divided by zero
A. NumberFormatException
B. ArithmeticException
C. NullPointerException
D. IllegalArgumentException
Correct : B. ArithmeticException
80. A single try block must be followed by which of these?
A. finally
B. catch
C. catch or finally
D. None of the mentioned
Correct : C. catch or finally
81. Which of these exceptions will occur if we try to access the index of an array beyond its length?
A. ArithmeticException
B. ArrayException
C. ArrayIndexException
D. ArrayIndexOutOfBoundsException
Correct : D. ArrayIndexOutOfBoundsException
82. Runnable is a
A. Class
B. Method
C. Variable
D. Interface
Correct : D. Interface
83. Thread priority in Java is represented as?
A. int
B. Float
C. double
D. long
Correct : A. int
84. Which of these class is used to make a thread?
A. String
B. System
C. Thread
D. Runnable
Correct : C. Thread
85. Which of these interface is implemented to create a Thread?
A. Runnable
B. Connections
C. Set
D. MapConnections
Correct : A. Runnable
86. Which of these method of Thread class is used to find out the priority given to a thread?
A. get()
B. ThreadPriority()
C. getPriority()
D. getThreadPriority()
Correct : C. getPriority()
87. Which of this method of Thread class is used to change the state of a thread to blocked state?
A. sleep()
B. terminate()
C. stop()
D. block()
Correct : A. sleep()
88. Which method in Thread class is used to check weather a thread is still running?
A. isAlive()
B. Join()
C. isRunning()
D. Alive()
Correct : A. isAlive()
89. Which of these methods is used to begin the execution of a thread?
A. run()
B. start()
C. runThread()
D. startThread()
Correct : B. start()
90. Which of these method waits for the thread to treminate?
A. sleep()
B. isAlive()
C. join()
D. stop()
Correct : C. join()
91. Which of these is used to read a string from the input stream?
A. get()
B. getLine()
C. read()
D. readLine()
Correct : D. readLine()
92. Which of these classes is used to read characters and strings in Java from console?
A. BufferedReader
B. StringReader
C. BufferedStreamReader
D. InputStreamReader
Correct : D. InputStreamReader
93. Which of these classes are used by Byte streams for input operation?
A. InputStream
B. InputOutputStream
C. Reader
D. All of the mentioned
Correct : A. InputStream
94. Which of these class contains the methods print() & println()?
A. System
B. System.out
C. BufferedOutputStream
D. PrintStream
Correct : D. PrintStream
95. Which of these methods can be used to write console output?
A. printout()
B. println()
C. write()
D. All of the mentioned
Correct : B. println()
96. Which of these classes are used by character streams output operations?
A. OutputStream
B. Writer
C. ReadStream
D. InputOutputStream
Correct : B. Writer
97. Which refers to a channel through which data flow from the source to the destination:
A. String
B. Character
C. Stream
D. Buffer
Correct : C. Stream
98. Java Stream classes can be categorized into two groups:
A. Byte and Character Stream Classes
B. Stream and String Classes
C. String and Character Stream Classes
D. Buffer and Character Stream Classes
Correct : A. Byte and Character Stream Classes
99. Byte Stream Classes support input/output operations on _____
A. 8 bit
B. 16 bit
C. 32 bit
D. 64 bit
Correct : A. 8 bit
100. Character Stream Classes support input/output operations on _______ characters:
A. 8 bit Unicode
B. 16 bit Unicode
C. 32 bit Unicode
D. 64 bit Unicode
Correct : B. 16 bit Unicode