CoreJava1
CoreJava1
arrA=new A[10];
arrB=new B[20];
arrA=arrB; //(1)
arrB=(B[])arrA; //(2)
arrA=new A[10];
arrB=(B[])arrA; //(3)
}
}
class A{}
class B extends A{}
Given the following program,which statement is true.
Select the correct answer.
1. The program will fail to compile because of the assignment at (1)
2. The program will throw a java.lang.ClassCast Exception in the
assignment at (2) when
run.
3. The program will throw a java.lang.ClassCast Exception in the
assignment at (3) when
run.
4. The program will compile and run without errors,even if the (B[]) cast
in the statements at (2) and (3) is removed.
Correct Answer : 3
Your Answer :
QuestionID : 9474 Subject Name Core Java
Q18. What is java virtual machine?
1. A hardware manifactured by SUN Microsystem,Inc.
2. A software
3. A device like chip embedded in computer harddisk
4. An Aplication
Correct Answer : 2
Your Answer :
QuestionID : 9481 Subject Name Core Java
Q19. Which method is used to determine the class of an object?
1. getClass()
2. getObject()
3. instanceOf()
4. forName()
Correct Answer : 1
Your Answer :
QuestionID : 9483 Subject Name Core Java
Q20. class Question72
{
public Question72()throws IOException
{
throw new IOExeception();
}
}
(a) String[ ] s;
(b) String [ ]s;
(c) String[ s];
(d) String s[ ];
1. a, b,c,d
2. a,b,d
3. b,c,d
4. a,c,d
Correct Answer : 2
Your Answer :
QuestionID : 9887 Subject Name Core Java
Q35. Which labeled line will generate error.
public class test
{
public static void main(String[] args)
{
char c;
int i;
c=`A`; //1
i=c; //2
c=i+1; //3
c++; //4
}
}
1. The line labeled 1
2. The line labeled 2
3. The line labeled 3
4. The line labeled 4
Correct Answer : 3
Your Answer :
QuestionID : 9932 Subject Name Core Java
Q36. Which of the following are true about the Error and Exception
classes?
1. Both classes extends Throwable
2. The error class is final and the exception class is not.
3. The exception class is final and the error class is not.
4. Both class implement Throwable.
Correct Answer : 1
Your Answer :
QuestionID : 9987 Subject Name Core Java
Q37. What class must an inner class extends.
1. The Top level class
2. Any class or interface
3. The object class
4. It must extend an interface
Correct Answer : 2
Your Answer :
QuestionID : 10034 Subject Name Core Java
Q38. Operand stack in java is a 32 bit wide
Correct Answer : T
Your Answer :
QuestionID : 10043 Subject Name Core Java
Q39. import java.io.*;
public class TestClass
{
public static void main(String args[]) throws IOException
{
PrintStream pr=new PrintStream(new FileOutputStream("outfile"));
System.out=pr;
System.out.println("Lets see what I see now??????");
}
}
1. compile time error
2. cannot assign a value to final variable out
3. the code compiles and run successfully .A file called "outfile" is
created and "lets see what i see now??" is printed in the same.
4. it will do nothing
Correct Answer : 2
Your Answer :
QuestionID : 10098 Subject Name Core Java
Q40. Given that a Button can generate an ActionEvent which listener would
you expect to have to implement, in a class which would handle this event?
1.
FocusListener
2. ComponentListener
3. WindowListener
4. ActionListener
Correct Answer : 4
Your Answer :
QuestionID : 10101 Subject Name Core Java
Q41. Exception is sub-class of error
Correct Answer : F
Your Answer :
QuestionID : 10162 Subject Name Core Java
Q42. What is the result of compiling and running the following code:
new Test();
public Test () {
System.out.println("In test");
System.out.println(this);
if (temp > 5) {
System.out.println(temp);
1. compiler error
2. equal
3. not equal
4. exception
Correct Answer : 3
Your Answer :
QuestionID : 10245 Subject Name Core Java
Q45. which of these methods from the collection interface will return the
value
true if the collection was modified during the operation
a.contains()
b.add()
c.containsAll()
d.retainAll()
e.clear()
1. b,d
2. c,d
3. d,a
4. d,e
Correct Answer : 1
Your Answer :
QuestionID : 10266 Subject Name Core Java
Q46. Which of the following are Java keywords (as opposed to reserved
words)?
1. goto
2. malloc
3. extends
4. FALSE
Correct Answer : 3
Your Answer :
QuestionID : 10440 Subject Name Core Java
Q47. memeber variables be synchronized
Correct Answer : T
Your Answer :
QuestionID : 10442 Subject Name Core Java
Q48. Abstract clases may contain final methods.
Correct Answer : T
Your Answer :
QuestionID : 10446 Subject Name Core Java
Q49. Garbage collection is a process that does,
1. reclaiming memory occupied by objects that are no longer needed and
making it available for new objects.
2. reclaiming memory occupied by objects that are no longer needed.
3. None
4. None
Correct Answer : 1
Your Answer :
QuestionID : 10517 Subject Name Core Java
Q50. When outer class is inherited then inner class is automaticaly inherited.
Correct Answer : F
Your Answer :