Core Java-2
This test consists of the questions related to Java ( core java) programming language in software programming.
Questions
Which method of the Throwable class returns the description of the exception in Java?
- void printStackTrace( )
- String getMessage( )
- String toString( )
- void printStackTrace(PrintWriter stream)
- String getLocalizedMessage( )
Which of the following is not a class of java.lang package?
- Math
- Number
- Thread
- System
- Date
Which of the following is true about 'finally' in Java?
- There should be a catch block to execute finally clause.
- Finally block is executed only when there is an exception in a program.
- JVM always executes finally block before terminating the program.
- Finally block can be put before catch block.
- Finally block can handle the exception in the code.
Which of the following is/are not the method(s) of the Iterator interface in collection framework?
- object next( )
- boolean hasNext( )
- void remove( )
- boolean hasPrevious( )
- Both (3) and (4)
Which of the following is not a method of SortedMap interface?
- Comparator comparator( )
- SortedMap subMap(Object start, Object end)
- SortedMap tailMap(Object start)
- SortedMap headMap(Object end)
- Set entrySet( )
Which of the following is not a reserved keyword in Java?
- goto
- short
- byte
- assert
- unsigned
Which of the following is true about Map.Entry interface?
- It stores the elements in a sequence.
- This interface defines the methods by which you can group the elements in a collection of objects.
- It extends Map interface so that the keys are maintained in ascending order.
- It describes an element in the form of key-value pair in a map. This is an inner class of Map interface.
- This interface does not allow duplicate interface.
Which method converts all the characters in a String object into a character array?
- charAt()
- toCharArray()
- getChars()
- getBytes()
- Both (1) and (2)
What is the role of stop() method in applet in Java?
- This method is called by the browser to unload the applet.
- This method is called by the browser, when applet is first loaded.
- This method is called by the browser, when an applet should start or resume its execution.
- 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.
- This method returns the URL associated with that applet.
Which of the following statements is false?
- start() method starts a thread by calling its run method.
- run() is an entry point for the thread.
- sleep() method temporarily suspends a currently executing thread.
- isAlive() method determines if a thread is still running.
- join() method waits for a thread to terminate.
Which exception is shown by the sleep() method in threads?
- IllegalArgumentException
- InterruptedException
- IllegalMonitorStateException
- IllegalStateException
- UnsupportedOperationException
What does InputStreamReader Class do in Java?
- This class gives buffered input character stream.
- This is an input stream that reads from a character array.
- This is an input stream that translates bytes to characters.
- This is an input stream that counts lines.
- This is an output stream that translates characters to bytes.
What is the range of byte?
- –2,147,483,648 to 2,147,483,647
- –32,768 to 32,767
- –128 to 127
- 0 to 255
- –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Which method of the String class is used to remove the leading and trailing blank spaces from the string?
- insert()
- delete()
- replace()
- trim()
- charAt()
Which of the following statements is false about constructors in Java?
- Constructors do not have return type.
- Constructor has the same name as that of the class.
- Constructors are called automatically upon object creation time.
- A constructor can be static.
- A constructor cannot be final.
Which of the following statements is false?
- Hashtable is synchronised.
- A list can contain duplicate elements but a set cannot.
- HashMap is used for non-threaded applications.
- ArrayList dynamically increases or decreases in size.
- ArrayList is synchronised.
Which of the following is not a true statement about abstract class in Java?
- Abstract class cannot be instantiated.
- Abstract class has both abstract and concrete methods.
- An abstract class has any public, private or protected members.
- A Java class can extend only one abstract class.
- A static method can be abstract in the abstract class.
What does ceil() method in Java return?
- This method returns the closest long or int, as indicated by the method's return type, to the argument.
- This method returns the smallest integer that is greater than or equal to the argument as a double.
- This method returns the largest integer that is less than or equal to the argument as a double.
- This method returns a String object representing the value of specified int or Integer.
- This method converts the primitive data type of a certain String.
Which of the following is not a method of Object class in Java?
- void finalize( )
- int hashCode( )
- Object clone( )
- int compareTo(Integer i)
- void notify( )
Which of the following is/are true about instanceOf method in Java?
- It is not a method in Java.
- By using this method, our program can obtain runtime type information about an object.
- It is used for generalised routines samples.
- Both (2) and (3)
- None of the above