Core Java-2

This test consists of the questions related to Java ( core java) programming language in software programming.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which method of the Throwable class returns the description of the exception in Java?

  1. void printStackTrace( )
  2. String getMessage( )
  3. String toString( )
  4. void printStackTrace(PrintWriter stream)
  5. String getLocalizedMessage( )
Question 2 Multiple Choice (Single Answer)

Which of the following is not a class of java.lang package?

  1. Math
  2. Number
  3. Thread
  4. System
  5. Date
Question 3 Multiple Choice (Single Answer)

Which of the following is true about 'finally' in Java?

  1. There should be a catch block to execute finally clause.
  2. Finally block is executed only when there is an exception in a program.
  3. JVM always executes finally block before terminating the program.
  4. Finally block can be put before catch block.
  5. Finally block can handle the exception in the code.
Question 4 Multiple Choice (Single Answer)

Which of the following is/are not the method(s) of the Iterator interface in collection framework?

  1. object next( )
  2. boolean hasNext( )
  3. void remove( )
  4. boolean hasPrevious( )
  5. Both (3) and (4)
Question 5 Multiple Choice (Single Answer)

Which of the following is not a method of SortedMap interface?

  1. Comparator comparator( )
  2. SortedMap subMap(Object start, Object end)
  3. SortedMap tailMap(Object start)
  4. SortedMap headMap(Object end)
  5. Set entrySet( )
Question 6 Multiple Choice (Single Answer)

Which of the following is not a reserved keyword in Java?

  1. goto
  2. short
  3. byte
  4. assert
  5. unsigned
Question 7 Multiple Choice (Single Answer)

Which of the following is true about Map.Entry interface?

  1. It stores the elements in a sequence.
  2. This interface defines the methods by which you can group the elements in a collection of objects.
  3. It extends Map interface so that the keys are maintained in ascending order.
  4. It describes an element in the form of key-value pair in a map. This is an inner class of Map interface.
  5. This interface does not allow duplicate interface.
Question 8 Multiple Choice (Single Answer)

Which method converts all the characters in a String object into a character array?

  1. charAt()
  2. toCharArray()
  3. getChars()
  4. getBytes()
  5. Both (1) and (2)
Question 9 Multiple Choice (Single Answer)

What is the role of stop() method in applet in Java?

  1. This method is called by the browser to unload the applet.
  2. This method is called by the browser, when applet is first loaded.
  3. This method is called by the browser, when an applet should start or resume its execution.
  4. This method is called by the browser to suspend execution of the applet and if it will be restarted again when browser returns that page by start() method.
  5. This method returns the URL associated with that applet.
Question 10 Multiple Choice (Single Answer)

Which of the following statements is false?

  1. start() method starts a thread by calling its run method.
  2. run() is an entry point for the thread.
  3. sleep() method temporarily suspends a currently executing thread.
  4. isAlive() method determines if a thread is still running.
  5. join() method waits for a thread to terminate.
Question 11 Multiple Choice (Single Answer)

Which exception is shown by the sleep() method in threads?

  1. IllegalArgumentException
  2. InterruptedException
  3. IllegalMonitorStateException
  4. IllegalStateException
  5. UnsupportedOperationException
Question 12 Multiple Choice (Single Answer)

What does InputStreamReader Class do in Java?

  1. This class gives buffered input character stream.
  2. This is an input stream that reads from a character array.
  3. This is an input stream that translates bytes to characters.
  4. This is an input stream that counts lines.
  5. This is an output stream that translates characters to bytes.
Question 13 Multiple Choice (Single Answer)

What is the range of byte?

  1. –2,147,483,648 to 2,147,483,647
  2. –32,768 to 32,767
  3. –128 to 127
  4. 0 to 255
  5. –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Question 14 Multiple Choice (Single Answer)

Which method of the String class is used to remove the leading and trailing blank spaces from the string?

  1. insert()
  2. delete()
  3. replace()
  4. trim()
  5. charAt()
Question 15 Multiple Choice (Single Answer)

Which of the following statements is false about constructors in Java?

  1. Constructors do not have return type.
  2. Constructor has the same name as that of the class.
  3. Constructors are called automatically upon object creation time.
  4. A constructor can be static.
  5. A constructor cannot be final.
Question 16 Multiple Choice (Single Answer)

Which of the following statements is false?

  1. Hashtable is synchronised.
  2. A list can contain duplicate elements but a set cannot.
  3. HashMap is used for non-threaded applications.
  4. ArrayList dynamically increases or decreases in size.
  5. ArrayList is synchronised.
Question 17 Multiple Choice (Single Answer)

Which of the following is not a true statement about abstract class in Java?

  1. Abstract class cannot be instantiated.
  2. Abstract class has both abstract and concrete methods.
  3. An abstract class has any public, private or protected members.
  4. A Java class can extend only one abstract class.
  5. A static method can be abstract in the abstract class.
Question 18 Multiple Choice (Single Answer)

What does ceil() method in Java return?

  1. This method returns the closest long or int, as indicated by the method's return type, to the argument.
  2. This method returns the smallest integer that is greater than or equal to the argument as a double.
  3. This method returns the largest integer that is less than or equal to the argument as a double.
  4. This method returns a String object representing the value of specified int or Integer.
  5. This method converts the primitive data type of a certain String.
Question 19 Multiple Choice (Single Answer)

Which of the following is not a method of Object class in Java?

  1. void finalize( )
  2. int hashCode( )
  3. Object clone( )
  4. int compareTo(Integer i)
  5. void notify( )
Question 20 Multiple Choice (Single Answer)

Which of the following is/are true about instanceOf method in Java?

  1. It is not a method in Java.
  2. By using this method, our program can obtain runtime type information about an object.
  3. It is used for generalised routines samples.
  4. Both (2) and (3)
  5. None of the above