Spaces:
Sleeping
Sleeping
File size: 7,243 Bytes
f187aae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
question,option1,option2,option3,option4,answer,difficulty
What is the size of an int in Java?,2 bytes,4 bytes,8 bytes,16 bytes,4 bytes,low
Which keyword is used to create a class in Java?,class,Class,new,create,class,low
What is the default value of a boolean variable?,true,false,null,undefined,false,low
Which method is used to print output in Java?,println(),display(),output(),print(),println(),low
What does JVM stand for?,Java Virtual Machine,Java Virtual Model,Java Verified Machine,Java View Model,Java Virtual Machine,low
Which operator is used for comparison in Java?,=,==,!=,<>,==,low
What is the entry point of a Java program?,main(),start(),run(),execute(),main(),low
What is the extension of compiled Java files?,.java,.class,.exe,.javac,.class,low
Which package is imported by default in Java?,java.util,java.lang,java.io,java.net,java.lang,low
Which keyword is used to inherit a class in Java?,extend,extends,inherit,inherits,extends,low
What is used to handle exceptions in Java?,try-catch,if-else,for loop,while loop,try-catch,low
Which of these is a reserved keyword in Java?,void,main,static,return,void,low
What does the 'final' keyword do?,Creates a constant variable,Creates a variable,Creates a loop,Creates a method,Creates a constant variable,low
Which data type is used to store a sequence of characters?,int,char,String,double,String,low
Which method is used to convert a string to lowercase?,toLowerCase(),toLower(),convertLower(),makeLowerCase(),toLowerCase(),low
What is the parent class of all classes in Java?,String,Object,Class,BaseClass,Object,low
What is the default value of an int variable?,0,-1,null,undefined,0,low
Which loop is used to iterate a fixed number of times?,for,while,do-while,foreach,for,low
Which access modifier allows visibility within the same package?,public,protected,default,private,default,low
What is the output of '5 + 2 + \"3\"' in Java?,10,523,73,Error,73,medium
Which interface is implemented for multithreading in Java?,Runnable,Thread,Callable,MultiThread,Runnable,medium
How do you define a constant in Java?,const,final,static,define,final,medium
Which exception is thrown when a thread is waiting or sleeping?,InterruptedException,IOException,NullPointerException,RuntimeException,InterruptedException,medium
Which method is used to stop a thread?,stop(),terminate(),shutdown(),halt(),stop(),medium
How are elements stored in a TreeSet?,Insertion order,Sorted order,Random order,Reverse order,Sorted order,medium
Which class is used for buffered input in Java?,BufferedReader,InputStreamReader,Scanner,FileReader,BufferedReader,medium
How do you serialize an object in Java?,By using Serializable interface,By using Externalizable interface,By using ObjectOutputStream,All of the above,All of the above,medium
What is the purpose of 'super' keyword in Java?,Access parent class methods,Access parent class constructor,Access parent class variables,All of the above,All of the above,medium
What is the default priority of a thread?,5,1,10,0,5,medium
Which method is called when an object is garbage collected?,finalize(),dispose(),clear(),delete(),finalize(),medium
Which of these are checked exceptions?,IOException,NullPointerException,ArrayIndexOutOfBoundsException,ArithmeticException,IOException,medium
What is the return type of 'compareTo()' method?,int,boolean,String,void,int,medium
Which method is used to compare two strings ignoring case?,compareTo(),compareToIgnoreCase(),equals(),equalsIgnoreCase(),compareToIgnoreCase(),medium
What is the result of '10 << 2'?,20,40,30,10,40,medium
What happens when you divide an integer by zero?,ArithmeticException,NullPointerException,Infinity,NaN,ArithmeticException,medium
How do you create an unmodifiable collection?,Collections.unmodifiableCollection(),Collections.immutableCollection(),Collections.staticCollection(),Collections.readOnlyCollection(),Collections.unmodifiableCollection(),medium
Which collection allows null values?,ArrayList,HashMap,HashSet,All of the above,All of the above,medium
What is the time complexity of accessing an element in HashMap?,O(1),O(n),O(log n),O(n log n),O(1),medium
Which stream is used for reading binary data?,InputStream,BufferedInputStream,FileInputStream,All of the above,All of the above,medium
What is the result of 'Math.floor(-2.5)?',-3.0,-2.0,2.5,-2.5,-3.0,high
How can you make a method synchronized in Java?,Use the synchronized keyword,Use the lock() method,Use the thread-safe interface,Use the sync block,Use the synchronized keyword,high
What is the purpose of 'volatile' keyword?,Ensures visibility of changes across threads,Prevents thread execution,Marks a variable as constant,Prevents garbage collection,Ensures visibility of changes across threads,high
What is the difference between '==' and 'equals()'?,'==' checks reference equality, 'equals()' checks content equality,'==' checks content equality, 'equals()' checks reference equality,Both are the same,Depends on implementation,'==' checks reference equality, 'equals()' checks content equality,high
Which design pattern is used by Java's runtime class?,Singleton,Prototype,Factory,Adapter,Singleton,high
What happens if a thread is interrupted while sleeping?,Throws InterruptedException,Continues sleeping,Ignores interruption,Terminates immediately,Throws InterruptedException,high
Which Java feature prevents modification of an object's state?,Immutability,Encapsulation,Abstraction,Polymorphism,Immutability,high
What is the output of 'System.out.println(10 + 20 + \"30\");'?,30,1030,2030,Error,1030,high
What does 'strictfp' modifier do?,Restricts floating-point calculations,Enables faster floating-point operations,Makes floating-point consistent,None of the above,Restricts floating-point calculations,high
Which Java feature allows runtime method resolution?,Polymorphism,Abstraction,Encapsulation,Inheritance,Polymorphism,high
What is a marker interface?,Interface with no methods,Interface with default methods,Interface with a single method,Interface with static methods,Interface with no methods,high
What is the purpose of 'ClassLoader' in Java?,Loads classes at runtime,Compiles classes,Links classes,Stores class metadata,Loads classes at runtime,high
How can you avoid deadlocks in Java?,Avoid nested locks,Use try-finally for locks,Use a timeout for locks,All of the above,All of the above,high
What is the result of 'Integer.parseInt(\"10\") + Integer.valueOf(\"20\")'?,1020,30,10,Error,30,high
How can you make an object eligible for garbage collection?,Set its reference to null,Call System.gc(),Remove all references,All of the above,All of the above,high
What is the default encoding for Java strings?,UTF-8,UTF-16,ASCII,ISO-8859-1,UTF-16,high
Which thread state indicates it is eligible to run but not running?,RUNNABLE,BLOCKED,WAITING,TERMINATED,RUNNABLE,high
What is the role of 'transient' keyword?,Prevents serialization,Ensures serialization,Excludes field during serialization,Includes static fields,Excludes field during serialization,high
What is the result of '0.1 + 0.2' in Java?,0.3,0.30000000000000004,0.2,Error,0.30000000000000004,high
How does 'HashMap' handle hash collisions?,Separate chaining,Linear probing,Open addressing,Rehashing,Separate chaining,high |