We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 6
S .
NO QUESTION ANSWER OPTION 1
Which of the following is a method of the A size() 1 ArrayList class? How do you declare an array in Java? A int[] arr = new int[5]; 2 What is the return type of the charAt() A char 3 method in the String class? Which class is used for reading files in D FileReader 4 Java? What does the FileWriter class do? B Reads files 5 What keyword is used for exception D try 6 handling in Java? Which of the following will cause a new A 7 FileNotFoundException? FileReader("file.txt") What method is used to add an element to A add() 8 an ArrayList? Which of the following is true about arrays A Fixed size 9 in Java? Which block is executed if an exception D try 10 occurs? What is the default size of an ArrayList in A 10 11 Java? Which method is used to remove an A remove() 12 element from an ArrayList? How do you find the length of an array? A arr.length 13 What does substring(0, 3) return for the A Hel 14 string "Hello"? What type of data structure is an C Array 15 ArrayList? Which method in String class checks if a A contains() 16 string contains a substring? What exception is thrown when trying to ArrayIndexOutOfBoun access an array index that is out of A 17 dsException bounds? Which method can be used to convert a A toLowerCase() 18 string to lowercase? What is the purpose of the finally block? A Always executes 19 ArrayList arr = new How do you create an ArrayList in Java? A 20 ArrayList(); Which method is used to check if an A isEmpty() 21 ArrayList is empty? Which method can be used to split a string A split() 22 into an array? How do you handle exceptions in Java? A try-catch 23 Which method returns the number of A length() 24 characters in a String? How do you write data to a text file in C FileWriter.write() 25 Java? What does the toString() method do for an A Converts it to a string 26 ArrayList? Which of the following can cause a Accessing an element C 27 NullPointerException? of a null array What is the output of "Hello".length()? A 5 28 Which class is used to read text from a A FileReader 29 file? How do you catch multiple exceptions in using multiple catch A 30 Java? blocks Which of the following methods can be C isEmpty() 31 used to check if a string is empty? How do you initialize an array of integers C int arr[] = new int[5]; 32 in Java? Which of the following is not a part of D throw 33 exception handling? Which method is used to convert a string C parseInt() 34 to an integer? What happens if you try to write to a read- A IOException 35 only file? Which method in the String class is used to A indexOf() 36 find the position of a character? 37. How can you sort an ArrayList? A Collections.sort(arr); 37 What is the output of A ello 38 System.out.println("Hello".substring(1));? What is a common cause of IOException? A File not found 39 new How do you append to a file in Java? A FileWriter("file.txt", 40 true); What will arr[0] return for an array A 1 41 declared as int[] arr = {1, 2, 3};? What method can be used to compare two B compareTo() 42 strings for equality? Which of the following statements is true It can store primitive C 43 about an ArrayList? types Which exception is thrown when a file FileNotFoundExceptio A 44 cannot be found? n How can you ensure a block of code runs C try 45 regardless of exceptions? What will happen if you attempt to read B EOFException 46 from a closed file? Which class is used to write data in a A PrintWriter 47 formatted way? How do you check if an ArrayList contains A contains() 48 a specific element? Which of the following is an example of a A IOException 49 checked exception? What is the purpose of BufferedReader? A Read data efficiently 50 How do you convert an ArrayList to an A toArray() 51 array? OPTION 2 OPTION 3 OPTION 4 length() getSize() count()
int arr[] = int[5]; int arr(5); int arr = new int(5);
String int boolean
Reader InputStreamReader All of the above
Writes files Both A and B None of the above
catch throw All of the above
new new BufferedReader() new File("file.txt") FileWriter("file.txt") insert() push() append()
Dynamic size Can store mixed types Can be resized
catch finally Both B and C
0 5 15
delete() pop() clear()
arr.size() length(arr) size(arr)
HelLo HelL Hello
Linked List Dynamic Array Tree
includes() indexOf() hasSubstring()
IllegalArgumentExcep NullPointerException IOException tion lower() lowercase() downCase() Executes if no Executes if an Never executes exception exception occurs ArrayList arr = List arr = new arr = new ArrayList(); ArrayList(); ArrayList(); isNull() length() size()
divide() separate() break()
catch-finally finally-catch exception-try
size() count() chars()
PrintWriter.write() Both A and B BufferedWriter.write()
Returns its size Returns its type Returns its elements
Calling a method on a Both A and B None of the above null object 4 6 0
FileWriter PrintWriter BufferedWriter
using one catch block using try blocks Both A and B
isBlank() Both A and B isNull()
int[] arr = new int[5]; Both A and B None of the above
try catch throws
toInteger() Integer.valueOf() convert()
FileNotFoundExceptio AccessDeniedExceptio Both A and C n n find() positionOf() locate()
arr.sort(); arr.order(); sort(arr);
H Hello llo
Array out of bounds Null pointer access Syntax error
new Both A and B None of the above FileReader("file.txt"); 0 2 3
equals() Both A and B contains()
It can grow It is synchronized It is fixed in size dynamically ArrayIndexOutOfBoun IOException Exception dsException catch finally throw