A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

Important Notice!

Dear users, compscibits.com is now permanently moved to compsciedu.com. Please update all your links and bookmarks accordingly. Soon, the site will be accessible through URL compsciedu.com only.

91. Which of these exceptions will be thrown if we use null reference for an arithmetic operation?
a. ArithmeticException
b. NullPointerException
c. IllegalAccessException
d. IllegalOperationException
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).NullPointerException

92. Which of these class is used to create user defined exception?
a. java.lang
b. Exception
c. RunTime
d. System
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).Exception

93. What is the output of this program?
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                int a[] = {1, 2,3 , 4, 5};
                for (int i = 0; i < 7; ++i) 
                    System.out.print(a[i]);
            }
            catch(ArrayIndexOutOfBoundsException e) 
            {
         System.out.print("0");         
            }
        }
    }
a. 12345
b. 123450
c. 1234500
d. Compilation Error
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).123450

94. What is the output of this program?
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                int a[] = {1, 2,3 , 4, 5};
                for (int i = 0; i < 5; ++i) 
                    System.out.print(a[i]);
                int x = 1/0;
            }
            catch(ArrayIndexOutOfBoundsException e) 
            {
         System.out.print("A");         
            }
            catch(ArithmeticException e) 
            {      
                System.out.print("B");
            }
        }
    }
a. 12345
b. 12345A
c. 12345B
d. Compilation Error
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).12345B

95. Which of these class provides various types of rounding functions?
a. Math
b. Process
c. System
d. Object
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).Math

96. Which of these methods return a smallest whole number greater than or equal to variable X?
a. double ceil(double X)
b. double floor(double X)
c. double max(double X)
d. double min(double X)
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).double ceil(double X)

97. Which of these method returns a largest whole number less than or equal to variable X?
a. double ceil(double X)
b. double floor(double X)
c. double max(double X)
d. double min(double X)
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).double floor(double X)

98. Which of function return absolute value of a variable?
a. abs()
b. absolute()
c. absolutevariable()
d. none of the mentioned
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).abs()

99. What is the output of this program?
    class A 
    {
         int x;
         int y;
         void display() 
         {
              System.out.print(x + " " + y);
         }
    }
    class Output 
    {
         public static void main(String args[]) 
         {
             A obj1 = new A();
             A obj2 = new A();
             obj1.x = 1;
             obj1.y = 2;
             obj2 = obj1.clone();
             obj1.display();
             obj2.display();
         }
    }
a. 1 2 0 0
b. 1 2 1 2
c. 0 0 0 0
d. System Dependent
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).1 2 1 2

100. What is the output of this program?
    class Output 
    {
         public static void main(String args[]) 
         {
             double x = 3.14;  
             int y = (int) Math.abs(x);
             System.out.print(y);
         }
    }
a. 0
b. 3
c. 3.0
d. 3.1
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).3