Q.1]
Class x and class y are the sub classes of class A. Class A has a method defined as accessMe().
Class x is within the same package as Class A where as class y is in some other package.
The method accessMe() is accessible to class x but not to class y .
What is the access specifier defined for accessMe() method?
A.Private
B.Friendly
C.Protected
D.Protected friend
Q.2]
Which class can be used to read bytes of data from a source?
A.,java.io.Read
B.,java.io.InputStream
C.java.InputStream
D.,java.io.Input.Stream
Q.3]
Which keyword is used for implementing an interface?
A.Handles
B.implements
C.extends
D.import
Q.4]
Consider the following steps:
1.Ensure that the class implements every method that has been declared in the interface.
2.Save the file with a .java extension.
3.Import the interface.
4.Compile the applet or application created.
5.Declare the class, and use the implements keyword followed by the name of the interface.
Which is the correct sequence to implement an interface?
A.1>2>3>4>5
B.3>5>1>2>4
C.5>2>1>4>3
D.2>5>3>4>1
Q.5]
Consider the following statements.
Statement A: An interface can be used to simulate multiple inheritance.
Statement B: A class can implement several interfaces.
Statement C: All the variable of an interface are static, final and public.
Statement D: All the methods of an interface are abstract.
Which of the following option is correct about the above statements?
A.Statement A and Statement B are True AND Statement C and Statement D are False.
B.Statement A is True AND Statement B, Statement C and Statement D are False.
C.Statement C and Statement B are True AND Statement A and Statement D are False.
D.Statement A, Statement B, Statement C, and Statement D are True.
Q.6]
Consider the following statements:
Statement A: Try is the only keyword used to handle the exception.
Statement B: Catch block is declared inside the try block.
Which of the following option is correct about the above statements?
A.Statement A is True and Statement B is False.
B.Statement A is False and Statement B is True.
C.Both, Statements A and B, are True.
D.Both, Statements A and B, are False.
Q.7]
Which method of ObjectOutputStream class can be used to write the contents of an object to a file?
A.writeObject()
B.writeFile()
C.write()
D.writeContent()
Q.8]
Which of the following features of Java enforces you to override all the methods without inheriting the class?
A.Static Class
B.Interfaces
C.Abstract classes
D.Final Class
Q.9]
Which of the following control is used to select only one option at a time?
The control also allows the user to enter the data if none of the available options is found to be suitable.
A.Textbox
B.ComboBox
C.Listbox
D.Textarea
Q.10]
Consider the following statements.
Statement A:interfaces are used to implement the inheritance between non-related classes.
Statement B:an abstract class and an interfaces are same.
Which of the following option is correct about the above statements?
A.Statement A is True and Statement B is False.
B.Statement B is True and Statement A is False.
C.Both, Statement A and Statement B, are True.
D.Both, Statement A and Statement B, are False.
Q.11]
Which of the following combinations of access specifiers CANNOT be used with the variables of an interface?
A.public and private
B.final and protected
C.protected and private
D.static and final
Q.12]
Which of the following class is used to transfer the data from the server to a client?
A.PrintStream
B.BufferedInputStream
C.BufferedStream
D.BufferedOutput
Q.13]
Sam is writing a Java code where he needs to declare an integer array that can hold 10 elements. Which of the following options is the correct declaration for Sam's requirement?
A.int numbers[11];
B.int [10] numbers;
C.int numbers[9];
D.int [10];
Q.14]
Consider the following statements : Statement A:out is an object encapsulated inside the System class.
Statement B:System class is used to display the output on the screen.
Which of the following options is True?
A.Statement A is True and Statement B is False.
B.Both, Statement A and Statement B, are True.
C.Both, Statement A and Statement B, are False.
D.Statement A is False and Statement B is True.
Q.15]
Which of the following option can be used to invoke a method named displaydetails of a java program named employee.java?
A.Employeeobject.displaydetails();
B.Employee employeeobject.displaydetails();
C.Employeeobject=new employee().displaydetails();
D.Employee employeeobject=new Employee();
employeeobject.displaydetails();
Q.16]
William has written the following program in java.
public class student
{
public static void main(String args[])
{
int array[] = {0,0};
int num1 =100;
try
{
System.out.println(num1/array[1]);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Error... Out of bounds");
}
}
}
what will be the output of the above program?
A.The program will not compile at all.
B.Arithmetic exception gets raised.
C.There will be an error indicating that the required catch is missing.
D.IndexOutOfBoundException gets raised.
Q.17]
Which class is the base class for the classes used for handling exceptions and errors?
A.Throwable
B.Exception
C.System
D.Class
Q.18]
Which of the following is NOT a situation when a NullPointer exception is thrown?
A.Calling the methods of a null object.
B.Accessing the attributes of a null object.
C.Using an object without allocating memory to it.
D.Deleting the attributes of a null object.
Q.19]
Consider the following statements.
Statement A: The behavior of the catch block is restricted to the statements in the preceding try block only.
Statement B: One try can have many catch statements and vice-versa.
Statement C: Finally block gets executed even if no exception is raised.
Statement D: There can be many finally blocks to handle the exception.
Which of the following options is True with respect to above statements?
A.Statement A and Statement C are True AND Statement B and Statement D are False.
B.Statement A is False AND Statement B, Statement C and Statement D are True.
C.Statement C and Statement B are True AND Statement A and Statement D are False.
D.Statement B, Statement C and Statement A are False AND Statement D is True.
Q.20]
Which of the following is the default layout manager for an frame?
A.CardLayout
B.BoxLayout
C.BorderLayout
D.FlowLayout
Q.21]
Which exception is represented by the expression 1/0?
A.NullPointerException
B.ArithmeticException
C.ArrayIndexOutOfBoundsException
D.NumericException
Q.22]
Consider the following statements:
Statement A: An Error class is derived from an Exception class.
Statement B: Error class is used for VirtualMachineError.
Which of the following options is True with respect to above statements?
A.Statement A is True and Statement B is False.
B.Both the Statements are True.
C.Statement A is False and Statement B is True.
D.Both the Statements are False.
ans c
Q.23]
John a programmer in IT Ltd has been assigned a task to develop an application so that it is accessible on a distributed network. The program should be able to handle the exceptions even if they don’t belong to the group of pre-defined exceptions.
How can John accomplish this task?
A.By defining user defined exceptions.
B.By using finally block.
C.By using number of catch blocks.
D.By using Exception class.
Q.24]
What will be the output of the following code snippet:
class IllegalValueException extends Exception
{
public String getMessage()
{
return "wrong values supplied";
}
}
class user{int val1, val2;
public user(int a, int b)
{
val1 = a;val2 = b;
}
void show() throws IllegalValueException
{
if((val1 < 0 ) || (val2 > 0)) throw new IllegalValueException();
System.out.println ("value 1 = " + val1);
System.out.println ("value 2 = " + val2);
}
}
public class trial
{
public static void main (String args[])
{
user u1 = new user(-2,20);
try
{
u1.show();
}
catch (IllegalValueException e)
{
System.out.println (e.getMessage());
}
}
}
A.The program will not give any output.
B."wrong values supplied", gets displayed.
C."Value 1 = -2"
"Value 2 = 20" gets displayed.
D.Exceptions would not be handled at all.
Q.25]
Which one of the following options is the correct reason for declaring main() method in a Java program as static?
A.No instance of the class is needed to execute static methods.
B.Because no other method can be declared as static.
C.Because its name is main.
D.Because no changes can be made to main() method.
Q.26]
Which statement is used to raise an exception when user enters invalid data?
A.throwable
B.final
C.Exception
D.throw
Cracking → Keygenning and Programming → my java quetions need solution04 Oct 2009, 13:30 ![]() 0
GURU379 04 Oct 2009, 13:31 #
please if sure.
You have to login or register to post comments. |


