Correct Answer: 3: DDW Tmjiw Njg5Mje
Correct Answer: 3: DDW Tmjiw Njg5Mje
correctly?
class A {
//InterruptedException is a direct subclass of Exception .
void f() throws ArithmeticException , InterruptedException{
div(5,5);
}
int div(int i, int j)throws ArithmeticException{
return i/j;
}
}
public class MyClass extends A{
void f()/*throws[...list of exception ...]*/{
try{
div(5,0);
}
catch (ArithmeticException e){
return;
}
throw new RuntimeException("ArithmeticException was expected.");
}
}
1. Does not need to specify any exception.
2. Need to specify that it throws ArithmeticException.
3. Need to specify that it throws InterrupteException.
4. Need to specify that it throws RuntimeException.
Correct Answer : 1
Your Answer :
QuestionID : 9376 Subject Name Core Java
Q23. What are all methods used for Inter thread communication ?
1. wait(),notify(),notifyAll()
2. yield(),resume(),suspend()
3. Both of the above
4. None of the above
Correct Answer : 3
Your Answer :
QuestionID : 9378 Subject Name Core Java
Q24. public class Prog1
{
public static void main(String[] args)
{
byte b=128;
int i=b;
system.out.println(i);
}
}
1. compilation error byte to char is not allowed
2. 128 is printed
3. compilation error as 128 is out of range of byte
4. compile fine will throw ClassCastException
Correct Answer : 3
Your Answer :
QuestionID : 9413 Subject Name Core Java
Q25. //Filename:MyClass.java
class MyClass
{
public static void main(String[] args)
{
MyClass a;
MySubclass b;
a=b; //(3)
b=a; //(4)
Which is the first line that will cause compilation to fail in the following
program.
Select one correct answer.
1. Line labelled (3).
2. Line labelled (1).
3. Line labelled (6).
4. Line labelled (4).
Correct Answer : 4
Your Answer :
QuestionID : 9414 Subject Name Core Java
Q26. public abstract class AbstractClass
{
public AbstractClass()
{
System.out.println("this is an abstract class constructor")
}
public void amethod()
{
System.out.println("this is method in abstract class");
}
}
1. compiler error -the method AbstractClass does not have valid return
type
2. compiler error -the class can not be declared as abstract as it does not
have a valid return type.
3. no compiler error-the class is not practically abstract class and can be
instantiated
4. No compiler error -the class can not be instantiated directly.It has to be
extended to non abstract class.The constructors of the extended class will call
the constuctor of abstract of the absract class(implicitly or expicitly).
Correct Answer : 4
Your Answer :
QuestionID : 9422 Subject Name Core Java
Q27. Which of the following are legal methods? (Select 2)
c. public aMethod();
public test()
{
setLayout(new FlowLayout());
add(bsouth);
add(bwest);
add(beast);
add(bnorth);
add(bcenter);
setLayout(new BorderLayout());
validate();
setSize(300,300);
setVisible(true);
}
boolean t=true;
boolean r;
}
1. the first digit printed is 1
2. the first digit printed is 2
3. the first digit printed is 3
4. the second digit printed is 2
Correct Answer : 3
Your Answer :
QuestionID : 9588 Subject Name Core Java
Q40. A vector class in java -------
a. is final.
b. is public.
c. is serializable
d. has a only one constructor.
e. implement java.util.List
1. only a.
2. only b.
3. b and c and e.
4. c and d.
Correct Answer : 3
Your Answer :
QuestionID : 9624 Subject Name Core Java
Q41. which of the following operator can be used both as an integer bit wise
oprator and a boolean logical oprator
1. ^
2. !
3. &
4. ~
Correct Answer : 3
Your Answer :
QuestionID : 9626 Subject Name Core Java
Q42. what will be the result of attempting to compile and run the following
class
public class assignment
{
public static void main(String args[])
{
int a,b,c;
b=10;
a=b=c=20;
System.out.println(a);
}
}
select the one answer
1. the code will fail to compile since the compiler will recognize that the
variable c in the assignment statement a=b=c=20;has not been initialized
2. the code will fail to compile because the assignment statement
a=b=c=20;is illegal.
3. the code will compile correctly and will display 10 when run
4. the code will compile correctly and display 20 when run
Correct Answer : 4
Your Answer :
QuestionID : 9633 Subject Name Core Java
Q43. static variables belongs to
1. class
2. object
3. both
4. none
Correct Answer : 1
Your Answer :
QuestionID : 9654 Subject Name Core Java
Q44. You can explicitly drop a object reference by setting the value
of a variable whose data type is a reference type to
1. null
2. NAN
3. 0
4. none of these
Correct Answer : 1
Your Answer :
QuestionID : 9666 Subject Name Core Java
Q45. Given the class
//File:Args.java
public class Args{
public static void main(String[] args){
System.out.println(args[0]+" "+args[args.length-1]);
}}
what would be the result of execution the following on the command line !
java Args In politics stupidity is not handicap
1. program will throw ArrayIndexOutofBoundException
2. program will print "In handicap"
3. program will print "java handicap"
4. program will print "Args handicap"
Correct Answer : 2
Your Answer :
QuestionID : 9675 Subject Name Core Java
Q46. What is True about the Static member variables of a class....
a)It is initialized to zero when the first object of class is created.
b)Only one copy of the member will exist throughout the class.
c)Static variables are normally used to maintain values common to the entire
class.
d)Static variables can be accessed only using static member functions.
1. a,b & c.
2. a,b,d.
3. only d.
4. all of the above.
Correct Answer : 4
Your Answer :
QuestionID : 9694 Subject Name Core Java
Q47. class AA{}
class BB extends AA{}
class Q6
{
public static void main(String[] args)
{
AA a=null;
BB b=(BB)a;
System.out.println(b);
System.out.println(b instanceof BB);
System.out.println(b instanceof AA);
}
}
1. program compiles correctly and print null,true,false.
2. program compiles correctly and print null,false,false.
3. compile time error at line no.8 as null value cannot be casted
4. run time error at line no. 8 as null value cannot be casted.
Correct Answer : 2
Your Answer :
QuestionID : 9708 Subject Name Core Java
Q48. public class Q10
{
public static void main(String [] args)
{
int i=10;
int j=10;
boolean b=false;
if(b=i==j)
System.out.println("True");
else
System.out.println("False");
}
}
1. Compilation error at line 9
2. runtime Exception at line 9
3. True
4. False
Correct Answer : 3
Your Answer :
QuestionID : 9710 Subject Name Core Java
Q49. You can achieve multiple inhritance in JAVA.
Correct Answer : F
Your Answer :
QuestionID : 9724 Subject Name Core Java
Q50. Allthe wrapper classes(Integer,Boolean,Float, Short,Long,Double and
Characters)
a.public
b.are serializable
c.are immutable
d.extend java.lang.Number
e.are final
1. a,b
2. a,b,c
3. a,b,d,e
4. a,b,c,d,e
Correct Answer : 3
Your Answer :
QuestionID : 9726 Subject Name Core Java
Q51. protected class example{
public static void main(String args[])
{
String test="abc";
test = test + test;
System.out.println(test);
}
}
1. The class does not compile because the top level class cannot be
protected
2. The program prints "abc"
3. the program print "abcabc"
4. The program does not compile access modifier. Select the one correct
answer
Correct Answer : 1
Your Answer :
QuestionID : 9791 Subject Name Core Java
Q52. Write down the modifier of a method that makes the method available
to all classes in the same package and to all the subclasses of this class.
1. private
2. protected
3. public
4. default
Correct Answer : 2
Your Answer :
QuestionID : 9827 Subject Name Core Java
Q53. What will happen if you compile/run this code?
1: int i = 16;
2: int j = 17;
3:
4: System.out.println("i >> 1 = " + (i >> 1));
5: System.out.println("j >> 1 = " + (j >> 1));
1. Prints i >> 1 = 8
j >> 1 = 8
2. Prints i >> 1 = 7
j >> 1 = 7
3. Prints i >> 1 = 8
j >> 1 = 9
4. Prints i >> 1 = 7
j >> 1 = 8
Correct Answer : 1
Your Answer :
QuestionID : 9977 Subject Name Core Java
Q65. Fields in the interfaces declare named constants, and are always
public, static, and final.
Correct Answer : T
Your Answer :
QuestionID : 10000 Subject Name Core Java
Q66. what will be the output of the following code?
public class TestClass implements Runnable
{
public void run()
{
while(true)
{
}
}
public static void main (String args[])
{
TestClass nt1=new TestClass();
TestClass nt2=new TestClass();
TestClass nt3=new TestClass();
nt1.run();
nt2.run();
nt3.run();
}
}
1. The code does not compile
2. the code compiles
and runs 3 non ending non demon threads.
3. the code compiles
and runs only 1 non ending non demon thread.
4. non of the above
Correct Answer : 3
Your Answer :
QuestionID : 10003 Subject Name Core Java
Q67. Java supports the modulus operation on the following data type?
1. Double
2. Char
3. Float
4. Short
Correct Answer : 3
Your Answer :
QuestionID : 10027 Subject Name Core Java
Q68. What command in the Java 2 SDK should be used to compile the
following code contained in a file called SmallProg.java?public class
SmallProg { public static void main(String[] args)
{ System.out.println("Good luck!"); }}
1. a. java SmallProg
2. b. javac SmallProg
3. c. java SmallProg.java
4. d. javac SmallProg.java
Correct Answer : 4
Your Answer :
QuestionID : 10035 Subject Name Core Java
Q69. Which of the following classes do not extend the java.lang.Number
class?
1. a. java.lang.Float
2. b. java.lang.Byte
3. c. java.lang.Character
4. d. java.lang.Short
Correct Answer : 3
Your Answer :
QuestionID : 10048 Subject Name Core Java
Q70. Which statement is true?
1. If an exception is thrown during the execution of the finalize() method
of an eligible object, then the exception is ignored and object is destroyed
2. All objects have a finalize() method
3. Objects can be destroyed by explicitly calling the finalize() method
4. The finalize() method can be declared with any accessibility
Correct Answer : 2
Your Answer :
QuestionID : 10076 Subject Name Core Java
Q71. The indexOf() method of java.lang.String class will return___________
on failure.
1. 0
2. false
3. -1
4. none of the above
Correct Answer : 3
Your Answer :
QuestionID : 10078 Subject Name Core Java
Q72. class A
{
int x=10;
}
class B extends A
{
int x=20;
}
class test
{
A a=new A();
B b=new B();
A z=new B();
System.out.println(a.x+" "+b.x+" "+z.x);
}
1. 10 20 20
2. 20 10 20
3. 10 20 10
4. 10 10 10
Correct Answer : 3
Your Answer :
QuestionID : 10090 Subject Name Core Java
Q73. How can a client prepare itself for callbacks from RMI server?
1. Extend java.rmi.server.UnicastRemoteObject
2. Call UnicastRemoteObject.exportObject()
3. Either of above will work
4. Neither of above will work
Correct Answer : 3
Your Answer :
QuestionID : 10092 Subject Name Core Java
Q74. How are remote object parameters transferred between client and
server?
1. A proprietary protocol that is determined by the vendor of the RMI
implementation
2. Standard Java Serialization
3. Internet Inter-ORB protocol(IIOP)
4. Java Remote Method Protocol(JRMP)
Correct Answer : 2
Your Answer :
QuestionID : 10131 Subject Name Core Java
Q75. Map can contain duplicate elements.
Correct Answer : F
Your Answer :
QuestionID : 10156 Subject Name Core Java
Q76. What is the permanent effect on the file system of writing data to a new
FileWriter("report"), given the file report already exists;?