Olete.in
Articles
Mock Tests
🧪 Java MCQ Quiz Hub
Java Mcq Question Set 1
Choose a topic to test your knowledge and improve your Java skills
1. Java is a ........... language.
moderate typed
strogly typed
weakly typed
none of these
2. How many primitive data types are there in Java?
5
6
7
8
3. In Java byte, short, int and long all of these are
signed
unsigned
Both of the above
None of these
4. Size of int in Java is
8 bit
16 bit
32 bit
64 bit
5. The smallest integer type is ......... and its size is ......... bits.
short, 8
byte, 8
short, 16
short, 16
6. Size of float and double in Java is
32 and 64
64 and 64
32 and 32
64 and 32
7. Automatic type conversion in Java takes place when
Two type are compatible and size of destination type is equal of source type.
Two type are compatible and size of destination type is larger than source type.
Two type are compatible and size of destination type is shorter than source type.
All of the above
8. Which of the following automatic type conversion will be possible?
byte to int
short to int
long to int
int to long
9. The following fraction of code double STATIC = 2.5 ; System.out.println( STATIC );
Prints 2.5
Raises an exception
Raises an error as STATIC is used as a variable which is a keyword
None of these
10. The following program: public class Test{ static boolean is OK; public static void main(String args[]){System.out.print(is OK); } }
Prints true
Prints false
Will not compile as boolean is not initialized
Will not compile as boolean can never be static
11. �In Java, the word true is ................
A Boolean literal
A Java keyword
Same as value 0
Same as value 1
12. What will the output of the following program? public class Test{ public static void main(String args[]){float f = (1 / 4) * 10; int i = Math.round(f); System.out.println(i); } }
0
1
2
3
13. �What is the output for the below code ? public class Test{public static void main(String[] args){int i = 010; int j = 07;System.out.println(i); System.out.println(j); } }
7 8
8 7
9 8
None
14. �What will be output of following program? public class Test{public static void main(String[] args){byte b=127; b++; b++; System.out.println(b); } }
127
-127
129
-129
15. �Which class cannot be subclassed (or extended) in java?
Final class
abstract class
parent class
None of above
16. Why we use array as a parameter of main method
Can store multiple values
It is syntax
Both of above
None of above
17. Suspend thread can be revived by using
yield() method
Suspend() method
start() method
resume() method
18. Runnable is
Interface
Class
Variable
Method
19. Which collection class associates values witch keys, and orders the keys according to their natural order
java.util.LinkedList
java.util.TreeMap
java.util.SortedSet
java.util.HashSet
20. Which method is used to perform DML statements in JDBC
executeUpdate()
executeQuery()
execute()
None of above
21. Which of the following below are valid isolation levels in J2EE
TRANSACTION_READ_UNCOMMITTED
TRANSACTION_SERIALIZABLE
Only A
Both A and B
22. Which metrhods are utilized to control the access to an object in multi threaded programming
Synchronized methods
Asynchronized methods
Serialized methods
None of above
23. Program which executes applet is known as
JVM
virtual machine
applet engine
None of above
24. Which statement is static and synchronized in JDBC API
getConnection()
executeQuery()
prepareCall()
executeUpdate()
25. The JDBC-ODBC bridge is
Singlethreaded
Multithreaded
Both of above
None of above
26. All raw data types should be read and uploaded to the database as an array of
int
byte
char
bollean
27. The class java.sql.Timestamp is associated with
java.util.Date
java.util.Time
java.sql.Time
None of above
28. Which of the following statements about arrays is syntactically wrong
arrayName[] p = new arrayName[5];
arrayName p[][] = new arrayName[2][];
arrayName[] p [];
arrayName p[5];
29. Converting a primitive type data into its corresponding wrapper class object instance is called
boxing
wrapping
autoboxing
instantiation
30. Package of drawstring() method is
java.awt
javax.swing
java.applet
java.io
31. Which method executes only once
stop() method
start() method
init() method
destroy() method
32. Object which can store group of other objects is called
Package
Wrapper
Java object
Collection object
33. All collection classes are available in
java.util package
java.io package
java.lang package
java.awt package
34. Thread class is available in
java.lang package
java.util package
java.awt package
java.io package
35. Minimum threads in a program are
0
1
2
3
36. JIT meaning
just in time
java in time
join in time
none of above
37. After the compilation of the java source code, which file is created by the JVM
.class
.doc
.java
.cdr
38. pow () is associated with which class
Input stream class
Object class
Math class
None of above
39. x=x+1 is equivalent to
x++
++x
x=x-1
None of these
40. If method have same name as class name and method don't have any return type then it is known as
Constructor
Destructors
Variable
Object
41. Methods that have same name, but different Parameter list and different definition known as
Overriding
Overloading
Constructor
none of these
42. Inheritance means
Sub class create object of super class
Sub class extends Base class
Sub class extends super class
All of the above
43. Which type of inheritance is not supported by java
Single
Mulilevel
Hirarchical
Multiple
44. String is the predefined
Object
Variable
Class
Method
45. Super is the predefined
Method
Keyword
Keyword and Method
None of above
46. Execution of the program is always begins with
Main method
parent class
default package
class contain main method
47. In java, gc() method is available in which package
java.io package
java.lang package
java.awt package
java.util package
48. JAR file contains the compressed version of
.java file
.jsp file
.class file
None of above
49. Process of creating exact copy of the existing object is called
overloading
overriding
cloning
coping
Submit