Method Overloading and Method Overriding
Method Overloading and Method Overriding
Questions
If there is a protected method within the Public class, then which of the following statements is correct?
- Protected method does not access the public method.
- Method is accessible from inside a class and a subclasses.
- Protected method is not allowed within the Public class.
- Method is accessible from inside the class and all the classes defined in the same package, where the class is defined itself.
Which of the following statements regarding 'finally' block in Java is false?
- Before the termination of the program, JVM executes the 'finally' block (if any).
- The 'finally' block can be used for writing the cleanup code.
- The 'finally' block must be followed by try or catch block.
- There can be multiple 'finally' blocks for a try block.
- The 'finally' block is not executed if the program exists.
The method readLine() can be accessed by the object of a ____________ class to read a string from console.
- InputStreamReader
- InputStream
- BufferedReader
- StringReader
What is the correct syntax of replace() method of the StringBuffer class?
- StringBuffer replace(int s,int e)
- StringBuffer replace(int s,String str)
- StringBuffer replace(int s,String str1,String str2)
- StringBuffer replace(int s,int e,String str)
The methods of NumberFormat class are used to display the numbers in standard formats(Currency values and percentage values).The NumberFormat class belongs to which of the following packages?
- java.lang
- java.io
- java.text
- java.txt
__________ methods cannot be overriden in a subclass.
- Final
- Finally
- Public
- Protected
___________ method creates and returns a copy of an object.
- copy()
- clone()
- xcopy()
- copyObject()
Which of the following methods of Process class in Java returns an input stream that reads input from the process out?
- destroy()
- getInputStream()
- getErrorStream()
- getOutputStream()
- exitValue()
Which of the following methods is called by the garbage collector when it determines that there are no more references to the object?
- final()
- finalize()
- collector()
- collection()
Which of the following methods in SmashTransition class is used to modify the work_pixels array for the next cell in Java?
- init()
- smash()
- tear()
- sleep()
- run()
Which of the following character methods in Java returns true value when argument provided with function is in uppercase letters?
- isUpperCase()
- toUpperCase()
- toLowerCase()
- toTitleCase()
- isLetter()
Which of the following statements is false regarding method overloading?
- When a class has multiple methods with the same name but different input parameters, then such methods are considered to be overloaded.
- Method overloading increases the readability of a program.
- Method overloading can be done by changing the number of input parameters.
- Method overloading can be done by changing the return type of method.
- Main() method can be overloaded.
Which of the following methods of Runtime class returns the approximate number of bytes of free memory available to the Java run-time system?
- gc()
- getRuntime()
- freeMemory()
- halt()
- totalMemory()
Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?
- java.lang.String
- java.lang.Double
- java.lang.StringBuffer
- java.lang.Character
Which of the following methods in Integer class returns a string that contains the decimal equivalent of the invoking object?
- toString()
- toBinaryString()
- shortValue()
- parseInt()
- hashCode()