Object & Classes


  1. Which of the following method of Process class can terminate a process?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Kills the subprocess. The subprocess represented by this Process object is forcibly terminated.


  1. Which of these class have only one field ‘TYPE’?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The Void class has one field, TYPE, which holds a reference to the Class object for the type void.



  1. What is the output of this program?
    public class Result 
    {
    public static void main(String args[])
    {
    Integer n = new Integer(260);
    byte p = n.byteValue();
    System.out.print(p);
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    n.byteValue() method returns the value of wrapper i as a byte value. n is 260, range of byte is 256 therefore n value exceeds byte range by 4 hence 4 is returned and stored in p.


  1. What is the output of this program?
    public class Result 
    {
    public static void main(String args[])
    {
    char array[] = {'P', '8', 'Q', ' '};
    System.out.print(Character.isDigit(array[1]) + " ");
    System.out.print(Character.isWhitespace(array[2]) + " ");
    System.out.print(Character.isUpperCase(array[0]));
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Character.isDigit(a[1]) checks for array[1], whether it is 8 digit or not, since array[1] i:e ‘8’ is a digit true is returned. array[4] is a whitespace hence Character.isWhitespace(array[2]) returns a false. array[0] is an uppercase letter i:e ‘P’ hence Character.isUpperCase(array[0]) returns true.



  1. Which of the following methods is a method of wrapper Integer for obtaining hash code for the invoking object?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    int hashCode()