Anda di halaman 1dari 13

QuestionID : 1199

Subject Name Core Java


Q1. Consider the following code:
if (number >= 0)
if (number > 0)
System.out.println("Number is positive");
else System.out.println("Number is negative");
What will be the output if number is equal to 0?
1. Number is negative
2. Number is positive
3. Both A and B
4. None of the above.
Correct Answer : 1
Your Answer :
QuestionID : 1209
Subject Name Core Java
Q2. The concept of multiple inheritance is implemented in Java by
1. extending two or more classes
2. extending one class and implementing one or more interfaces
3. implementing two or more interfaces
4. All the above.
Correct Answer : 2
Your Answer :
QuestionID : 1216
Subject Name Core Java
Q3. Which keyword can protect a class in a package from accessibility by the
classes outside the package?
1. private
2. protected
3. Final
4. Don`t use any keyword at all (make it default)
Correct Answer : 4
Your Answer :
QuestionID : 1242
Subject Name Core Java
Q4. What is wrong in the following class definitions?
abstract class Print{abstract show( );}
class Display extends Print{}
1. Nothing is wrong
2. Wrong. Mehtod show( ) should have a return type
3. Wrong. Method show( ) is not implemented in Display
4. Wrong. Display does not contain any members
Correct Answer : 2
Your Answer :
QuestionID : 1243
Subject Name Core Java
Q5. What is the error in the following class definitions?
abstract class SY{abstract sum(int x, int y) { }}
1. Class header is not defined properly
2. Constructor is not defined
3. Method is not defined properly

4. No error
Correct Answer : 3
Your Answer :
QuestionID : 1282
Subject Name Core Java
Q6. It is perfectly legal to assign a subclass object to a superclass referacence.
Correct Answer : T
Your Answer :
QuestionID : 1312
Subject Name Core Java
Q7. Any class may be inherited by another class in the package.
Correct Answer : T
Your Answer :
QuestionID : 1317
Subject Name Core Java
Q8. A method declared as static cannot access non-static class members.
Correct Answer : T
Your Answer :
QuestionID : 1326
Subject Name Core Java
Q9. A catch can have comma-separated multiple arguments.
Correct Answer : F
Your Answer :
QuestionID : 1328
Subject Name Core Java
Q10. A final class may not have any abstract methods.
Correct Answer : T
Your Answer :
QuestionID : 1374
Subject Name Core Java
Q11. It is always necessary to extend a JFrame class to write a swing
application.
Correct Answer : F
Your Answer :
QuestionID : 1390
Subject Name Core Java
Q12. Declaring a method synchronized guarantees that the deadlock cannot
occur.
Correct Answer : T
Your Answer :
QuestionID : 1393
Subject Name Core Java
Q13. A Java monitor must either extend Thread class or implement Runnable
interface
Correct Answer : F
Your Answer :
QuestionID : 1404
Subject Name Core Java
Q14. The setBackground() method is part of the class
1. Graphics
2. Applet
3. Component
4. Container
Correct Answer : 3
Your Answer :

QuestionID : 9301
Subject Name Core Java
Q15. A container have multiple layout managers
Correct Answer : F
Your Answer :
QuestionID : 9321
Subject Name Core Java
Q16. Class fields with following modifiers will not be serialized
1. private
2. static
3. finaly
4. protected
Correct Answer : 2
Your Answer :
QuestionID : 9323
Subject Name Core Java
Q17. which of these array declare statements are not legal?
1.int[] i[]={{1,2},{1},{},{1,2,3}};
2.int i[]=new int[2] {1,2};
3.int i[][]=new int[][] {{1,2,3},{4,5,6}};
4.int i[][]={{1,2},new int[2]};
5.int i[4]={1,2,3,4};
1. 1,2,3
2. 2,5
3. 2,3,5
4. 2,4,5
Correct Answer : 2
Your Answer :
QuestionID : 9361
Subject Name Core Java
Q18. What interface must all interfaces for remote services exted?
1. java.rmi.RemoteService
2. java.rmi.Remotable
3. java.rmi.Remote
4. java.rmi.server.Remote
Correct Answer : 3
Your Answer :
QuestionID : 9367
Subject Name Core Java
Q19. which statement are true?
1. the class thrad is abstract.
2. the class thread implements runnable
3. a program terminates when the last non-daemon thread ends
4. both 2 and 3
Correct Answer : 4
Your Answer :
QuestionID : 9369
Subject Name Core Java
Q20. Which of the following methods helps in getting the local host ip?
1. getLocalHost()
2. getRemoteHost()
3. getIpAddress()

4. getHost()
Correct Answer : 1
Your Answer :
QuestionID : 9426
Subject Name Core Java
Q21. import java.awt.*;
public class TestFrame2 extends Frame
{
public TestFrame2()
{
CheckboxGroup chg=null;
Checkbox ch=new Checkbox("Test",true,chg);
setLayout(new FlowLayout());
add(ch);
pack();
setVisible(true);
}
public static void main(String[] args)
{
TestFrame2 tf=new TestFrame2();
}
}
An attempt to compile and run the above code
1. will cause a compilation error as the chechbox group is null in the
constructor.
2. will compile successfully but throws a runtime exception because the
checkbox group is null in the constructor of the checkbox.
3. will compile and run successfully. The checkbox appears as a single
radio button which is always true.
4. will compile and run successfully.The checkbox bears its original
appearance and does not appear as a radio button.
Correct Answer : 3
Your Answer :
QuestionID : 9457
Subject Name Core Java
Q22. Which statements are ture about the use of modifiers?
select the two correct answers?
1.If no accessibility modifier is specified for a member declaration
the member is only accessible for classes in the package of its
class and subclasses of its class anywhere.
2.You cannot specify acessibility of local variable. They are only accessible
within the block in which they are declared.
3.subclasses of a class must reside in the same package as the calss they

extend.
4 Local variables can be decalred static.
5. Object themselves do not have any accessibilty modifiers,only
the object references do.
1. 1,2,3
2. 2,4,5
3. 3,4,5
4. 2,5
Correct Answer : 4
Your Answer :
QuestionID : 9466
Subject Name Core Java
Q23. import java.awt.*;
public class test extends Frame
{
Button bnorth=new Button("NORTH");
Button bsouth=new Button("South");
Button beast=new Button("East");
Button bwest=new Button("West");
Button bcenter=new Button("Center");
public test()
{
setLayout(new FlowLayout());
add(bsouth);
add(bwest);
add(beast);
add(bnorth);
add(bcenter);
setLayout(new BorderLayout());
validate();
setSize(300,300);
setVisible(true);
}
public static void main(String args[])
{
test t=new test();
}
}

1. will compile and run but no component is visible


2. will causes a compilation error - a layout cannot be set after component
has
been added with preset layout manager
3. will causes a runtime error - a layout cannot be set after component has
been added with preset layout manager
4. will compile and throws no runtime exception.Only the button with
"center
" is visible and occupies whole screen
Correct Answer : 1
Your Answer :
QuestionID : 9555
Subject Name Core Java
Q24. Which of the Following is not java primitive
1. Boolean
2. Long
3. Float
4. String
Correct Answer : 4
Your Answer :
QuestionID : 9563
Subject Name Core Java
Q25. What is the purpose of the main() method?
1. To hold the APIS of the application
2. To create the Buttons and scrollabars
3. To act as entry point for the program
4. none of the above
Correct Answer : 3
Your Answer :
QuestionID : 9587
Subject Name Core Java
Q26. getByName() throws ____________ Exception
1. UnknownHost
2. illegalAccess
3. NullPointer
4. All of the above
Correct Answer : 1
Your Answer :
QuestionID : 9596
Subject Name Core Java
Q27. public class ADirtyOne
{
char a=`\u000A`;
}
Any Attempt to compile above class
1. will complete successfully
2. will not compile as 0x000A is out of range for unicode characters
3. will complain about illegal character assignment
4. will compile but will cause a runtime error in accessing the variable

Correct Answer : 3
Your Answer :
QuestionID : 9652
Subject Name Core Java
Q28. what will be result of attemptring to comple & run following program
public class Myclass
{
public satatic void main(String [] args)
{RuntimeException re=null;
throw re;
}
}
select correct answer
1. program fail to compile ,since it cannot throw re
2. program will complile without error& will throw
java.lang.RuntimeException when run
3. program will complile without error& will throw
java.lang.NullpointerException when run
4. program will complile without error& will run & terminate without any
o/p
Correct Answer : 3
Your Answer :
QuestionID : 9656
Subject Name Core Java
Q29. A method declaring that it throws a certain exception class may throw
instances of any subclass of that exception class
Correct Answer : T
Your Answer :
QuestionID : 9828
Subject Name Core Java
Q30. Which of the following is illegal:
A) int i = 32;
B) float f = 45.0;
C) double d = 45.0;
D) NONE
Select the most appropriate answer.

1. A
2. B
3. C
4. D
Correct Answer : 2
Your Answer :
QuestionID : 9903
Subject Name Core Java
Q31. Which of the following are acceptable?

A) Object o = new Button("A");


B) Boolean flag = true;
C) Frame f = new Panel();
D) Panel p = new Applet();
Select all correct answers.
i) A,B
ii) A,B,C
iii)A,D
iv)ALL

1. i
2. ii
3. iii
4. iv
Correct Answer : 3
Your Answer :
QuestionID : 9924
Subject Name Core Java
Q32. clone method is of class
1. Clonable
2. Object
3. Class
4. None of the above
Correct Answer : 2
Your Answer :
QuestionID : 9926
Subject Name Core Java
Q33. What is the effect of issuing a wait() method on an object
1. If a notify() method has already been sent to that object then it has no
effect
2. The object issuing the call to wait() will halt until another object sends
a notify() or notifyAll() method
3. An exception will be raised
4. The object issuing the call to wait() will be automatically synchronized
with any other objects using the receiving object.
Correct Answer : 2
Your Answer :
QuestionID : 9956
Subject Name Core Java
Q34. Which variables can an inner class access from the class which
encapsulates it?
1. All static variables,all final variable ,all instance variable.
2. Only final static variables
3. Only final instance variables
4. only public variable
Correct Answer : 1
Your Answer :

QuestionID : 10012
Subject Name Core Java
Q35. what will be the output of the following code?
public class TestClass
{
public static void main(String args[])
{
if(0.0==-0.0)
{
System.out.println("equal");
}
else
System.out.println("unequal");
}
}
1. equal
2. unequal
3. compile time error
4. none of these
Correct Answer : 1
Your Answer :
QuestionID : 10059
Subject Name Core Java
Q36. How do you change the current layout manager for container?
1. use setLayout()
2. once created you cannot change it
3. You set setLayoutManager()
4. use updateLayout()
Correct Answer : 1
Your Answer :
QuestionID : 10074
Subject Name Core Java
Q37. In following program finally will executetry
{
int a=5;
int b=0;
int c=a/b;
System.exit(0);
}
catch(Exception e)
{
System.out.println(e);
}
finally
{
System.out.println("In Finally");
}
Correct Answer : T

Your Answer :
QuestionID : 10108
Subject Name Core Java
Q38. You are creating application that has a form with a text entry field used
to enter a person age.Which of he following is appropriate for caputring this
information.
1. USe the Text field of a TextField parse the result using Integer
2. Use the getInteger method of the TextField
3. Use the getText method of the TextBox and parse the result using the
getInt method of Integer class
4. Use the getText method of the TextField parse the result using the
parseInt method of Integer class
Correct Answer : 4
Your Answer :
QuestionID : 10113
Subject Name Core Java
Q39. What is the result of executing the following code, using the parameters
4 and 0:

public void divide(int a, int b) {


try {
int c = a / b;
} catch (Exception e) {
System.out.print("Exception ");
} finally {
System.out.println("Finally");
}
1. Prints out: Exception Finally
2. Prints out: Finally
3. Prints out: Exception
4. No output
Correct Answer : 1
Your Answer :
QuestionID : 10137
Subject Name Core Java
Q40. Which is not keybord in java.
1. final
2. volatile
3. unsigned
4. long

Correct Answer : 3
Your Answer :
QuestionID : 10175
Subject Name Core Java
Q41. Which method can be used to enable/disable a checkbox menu item?
1. setVal(boolean)
2. setState(boolean)
3. setStatus(boolean)
4. setItem(boolean)
Correct Answer : 2
Your Answer :
QuestionID : 10212
Subject Name Core Java
Q42. what makes the java platform dependent
1. thread
2. AWT
3. both of above
4. none of above
Correct Answer : 3
Your Answer :
QuestionID : 10289
Subject Name Core Java
Q43. Which methods can be legally applied to a string object?
a)equals(String)
b)equals(Object)
c)trim()
d)round()
e)toString()
1. a,b
2. a,e
3. a,b,d,e
4. a,b,c,e
Correct Answer : 4
Your Answer :
QuestionID : 10297
Subject Name Core Java
Q44. class test
{
public static void main(String[] args)
{
String str1="Hello";
String str2=new String("Hello");
if(str1.equals(str2))
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}
1. Equal
2. Not Equal

3. compile time error


4. Run time error
Correct Answer : 1
Your Answer :
QuestionID : 10298
Subject Name Core Java
Q45. class outer
{
private int i=10;
public void test()
{
inner obj=new inner();
System.out.println("j="+j);
}
class inner
{
private int j=20;
}
}
public class demo
{
public static void main(String[] args)
{
outer ob=new outer();
ob.test();
}
}
1. Compiler Error- Cannot resolve symbol j
2. Compile successfully and print 20
3. Compile successfully and print 0
4. None of the Above
Correct Answer : 1
Your Answer :
QuestionID : 10473
Subject Name Core Java
Q46. ClassLoader is a public class and extends object class
Correct Answer : T
Your Answer :
QuestionID : 10496
Subject Name Core Java
Q47. name of class file of inner class contain which of the
following character.
1. %
2. @
3. $
4. none of the above.
Correct Answer : 3
Your Answer :

QuestionID : 11002
Subject Name Core Java
Q48. Fields in interfaces are always public , static and final
Correct Answer : T
Your Answer :
QuestionID : 11040
Subject Name Core Java
Q49. Iterator has method to remove element.
Correct Answer : T
Your Answer :
QuestionID : 11042
Subject Name Core Java
Q50. Read object method reconstructs object at the time of retriving from the
file.
1. bit by bit
2. Byte by Byte
3. Whole object at a time.
4. Element by Element
Correct Answer : 2
Your Answer :