0% found this document useful (0 votes)
3 views

java (7)

The document contains a series of multiple-choice questions related to Core Java, along with the correct answers and the user's answers. The questions cover various topics such as command line options, data types, layout managers, and object-oriented programming concepts. The user scored 0 out of the total questions attempted.

Uploaded by

adef17354
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

java (7)

The document contains a series of multiple-choice questions related to Core Java, along with the correct answers and the user's answers. The questions cover various topics such as command line options, data types, layout managers, and object-oriented programming concepts. The user scored 0 out of the total questions attempted.

Uploaded by

adef17354
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

Close this Window Hi dac69, You have scored : 0


QuestionID : 1189 Subject Name Core Java
Q1. Which of the following command line options generates documentation
for all classes and methods?
1. public
2. private
3. verbose
4. encoding
Correct Answer : 3
Your Answer :
QuestionID : 1226 Subject Name Core Java
Q2. Which of the following will produce a value of 22 if x = 22.9?
1. ceil(x)
2. round(x)
3. abs(x)
4. floor(x)
Correct Answer : 4
Your Answer :
QuestionID : 1231 Subject Name Core Java
Q3. The range of values for the short type data is
1. 127 to -128
2. 32767 to -32768
3. 263 to -264
4. 232e+10 to 232 e-10
Correct Answer : 2
Your Answer :
QuestionID : 1336 Subject Name Core Java
Q4. If getParameter( ) returns null, then assigning the return value to a
variable of type String may cause an exception to be thrown.
Correct Answer : F
Your Answer :
QuestionID : 1350 Subject Name Core Java
Q5. If a frame uses a Grid layout manager and does not contain any panels,
then all the components within the frame are of the same width and height.
Correct Answer : T
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 1/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

Your Answer :
QuestionID : 1376 Subject Name Core Java
Q6. AWT has different classes for radio buttons and checkboxes.
Correct Answer : T
Your Answer :
QuestionID : 9312 Subject Name Core Java
Q7. how are remote object parameters transferred between client and server
1. services must extend the remote interface
2. the skeelton file must be present for the server
3. the server must be runing before its service can be used
4. all of the above are no longer true
Correct Answer : 2
Your Answer :
QuestionID : 9405 Subject Name Core Java
Q8. Which of the following collection classes from java.util package are
thread safe?
1. Vector
2. ArrayList
3. HashMap
4. HashNode
Correct Answer : 1
Your Answer :
QuestionID : 9414 Subject Name Core Java
Q9. 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
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 2/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

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 : 9460 Subject Name Core Java
Q10. Read the code carefully

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 BorderLayout());
add(bsouth,BorderLayout.SOUTH);
add(bwest,BorderLayout.WEST);
add(beast,BorderLayout.EAST);
add(bnorth,BorderLayout.NORTH);

add(bcenter);

setLayout(new FlowLayout());
validate();
pack();
setVisible(true);
}

public static void main(String args[])


{
test t=new test();

}
}
1. compilation Error-layout cannot be set twice for a component.
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 3/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

2. compilation Error-one button is added without specifing the position in


the

border layout.
3. No compilation error- buttons are arranged in a line in the order (from
left

to right)
"north","south","west","east","center"
4. No compilation error- buttons are arranged in a line in the order (from
left

to right)
"south","west","east","north","center"
Correct Answer : 4
Your Answer :
QuestionID : 9477 Subject Name Core Java
Q11. Tree Map class is used to implement which collection interface.
select the one correct answer.
1. Tree
2. Sorted Set
3. List
4. Sorted Map
Correct Answer : 4
Your Answer :
QuestionID : 9494 Subject Name Core Java
Q12. Which of following are legal statements?

a)String s=(String)100;
b)Float f=1.2f;
c)double d=0;
d)String str="s";
1. a,b,c
2. b,c,d
3. only b and d
4. only c and d
Correct Answer : 4
Your Answer :
QuestionID : 9503 Subject Name Core Java
Q13. public class Outer
{
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 4/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

public void doIt()


{
}
public class Inner
{
public void doIt()
{
}
}
public static void main(String[] args)
{
new Outer().new Inner().doIt();
}
}
Which statements are true about the following program?
Select the two correct answers.
(a)The doIt() method in the Inner class overrides the doIt() method in the
Outer class.
(b)The doIt() method in the Inner class overloads the doIt() method in the
Outer class.
(c)The doIt() method in the Inner class hides the doIt() method in the Outer
class.
(d)The full name of the Inner calss is Outer.Inner.
1. (a) & (b)
2. (c) & (b)
3. (a) & (d)
4. (c) & (d)
Correct Answer : 4
Your Answer :
QuestionID : 9525 Subject Name Core Java
Q14. if("String".replace(`T`,`t`) =="String")
System.out.println("Equal");
else
System.out.println(" not Equal");
1. the code will compile and print Equal
2. the code will compile and print not Equal
3. the code will cause compile error
4. ..
Correct Answer : 1
Your Answer :
QuestionID : 9542 Subject Name Core Java
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 5/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

Q15. Sharing of CPU time is called as Time slicing or Time sharing.


Correct Answer : T
Your Answer :
QuestionID : 9566 Subject Name Core Java
Q16. Java supports multi-dimensional Arrays.
Correct Answer : T
Your Answer :
QuestionID : 9575 Subject Name Core Java
Q17. Which of the following are reserved keywords?

a. public
b. static
c. void
d. main
e. String
f. args
1. a,b,c
2. a,b,d
3. a,c,d,e,f
4. all of these.
Correct Answer : 1
Your Answer :
QuestionID : 9583 Subject Name Core Java
Q18. Which of the folowing primitive data type is not integer type?
1.type boolean
2.type byte
3.type float
4.type short
5.type double.
1. 2 and 3
2. 1,3 and 5
3. 2 and 5
4. 4 and 5
Correct Answer : 2
Your Answer :
QuestionID : 9595 Subject Name Core Java
Q19. Class class1
{
static{
System.out.println(Thread.getCurrentThread().getName());

file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 6/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

int meth1(int i)
{
System.out.println(i);
return 0;
}
public static void main(String[] args)
{
System.out.println(Class.for.getName());
int i=0;
i=i++ + meth1(i);
System.out.println(i);

}
1. prints jvm main thread name,class1,1,0.
2. prints null,name,class1,1,0.
3. program compiles successfully and give the thread name .
4. none of above.
Correct Answer : 4
Your Answer :
QuestionID : 9649 Subject Name Core Java
Q20. which will following expression evaluted using floating-point
arithematic
select one answer
1. 2.0*3.0
2. 2*3
3. 2/3 + 5/7
4. 4*5
Correct Answer : 1
Your Answer :
QuestionID : 9675 Subject Name Core Java
Q21. 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.
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 7/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

2. a,b,d.
3. only d.
4. all of the above.
Correct Answer : 4
Your Answer :
QuestionID : 9703 Subject Name Core Java
Q22. Read the piece of code carefully

if("string".substring(0,6)=="string")
System.out.println("Equal");
else
System.out.println("Not Equal");
1. the code will compile and print "Equal"
2. the code will compile and print "Not Equal"
3. the code will cause a copiler error
4. none of the above
Correct Answer : 1
Your Answer :
QuestionID : 9725 Subject Name Core Java
Q23. which statements are valid when occuring their own
1. while()break;
2. do{break;}while(true);
3. if(true){break;}
4. none of the above
Correct Answer : 2
Your Answer :
QuestionID : 9827 Subject Name Core Java
Q24. What will happen if you compile/run this code?

1: public class Q1 extends Thread


2: {
3: public void run()
4: {
5: System.out.println("Before start method");
6: this.stop();
7: System.out.println("After stop method");
8: }
9:
10: public static void main(String[] args)
11: {
12: Q1 a = new Q1();
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 8/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

13: a.start();
14: }
15: }
1. Compilation error at line 7.
2. Runtime exception at line 7.
3. Prints "Before start method" and "After stop method".
4. Prints "Before start method" only.
Correct Answer : 4
Your Answer :
QuestionID : 9831 Subject Name Core Java
Q25. What is output System.out.println(12/0.0);
1. Infinity
2. Divide by zero Exception
3. NaN
4. Compile time error
Correct Answer : 1
Your Answer :
QuestionID : 9833 Subject Name Core Java
Q26. when using the GridBag Layout manger each new component require a
new instance of the GridBag constraint class?
Correct Answer : F
Your Answer :
QuestionID : 9885 Subject Name Core Java
Q27. Given the following classes defined in separate files:

class Vehicle{
public void drive(){
System.out.println("Vehicle: drive");
}
}

class Car extends Vehicle{


public void drive(){
System.out.println("Car: drive");
}
}

public class Test{


public static void main (String args []) {
Vehicle v;
Car c;
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 9/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

v = new Vehicle();
c = new Car();
v.drive();
c.drive();
v = c;
v.drive();
}
}

What will be the effect of compiling and running this class Test?
1. Generates a Compiler error on the statement v= c;
2. Generates runtime error on the statement v= c;
3. Prints out:
Vehicle: drive
Car: drive
Car: drive
4. Prints out:
Vehicle: drive
Car: drive
Vehicle: drive
Correct Answer : 3
Your Answer :
QuestionID : 9903 Subject Name Core Java
Q28. 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
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 10/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

Correct Answer : 3
Your Answer :
QuestionID : 9909 Subject Name Core Java
Q29. Which of the following are short-circuit operators in java
1.&&
2.||
3.?:
1. 1&2
2. 1&3
3. none of the above
4. all of the above
Correct Answer : 1
Your Answer :
QuestionID : 9936 Subject Name Core Java
Q30. Does this code will compile?
class base
{
int x=10;
}
class sib1 extends base
{
int y=20;
}
class sib2 extends base
{
int z=30;
}
public class test
{
public static void main(String[] args)
{
base bs= new base();
sib1 a=new sib1();
sib2 b=new sib2();
a=b;
}
}
1. It will give error due to base reference compatibility
2. It will give runtime error
3. It will give compile time error due to incompatibility
4. Code will run smoothly
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 11/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

Correct Answer : 3
Your Answer :
QuestionID : 9938 Subject Name Core Java
Q31. The layout of a container can be altered using which of the following
methods:

1. setLayout(aLayoutManager);
2. addLayout(aLayoutManager);
3. layout(aLayoutManager);
4. setLayoutManager(aLayoutManager);
Correct Answer : 1
Your Answer :
QuestionID : 9958 Subject Name Core Java
Q32. What is the output of the following 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 : 9964 Subject Name Core Java
Q33. What is the return type of method round(double) of Math Class?
1. short
2. int
3. double
4. long
Correct Answer : 4
Your Answer :
QuestionID : 10035 Subject Name Core Java
Q34. Which of the following classes do not extend the java.lang.Number
class?
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 12/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

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 : 10049 Subject Name Core Java
Q35. standard parameters of scrollbar are :
scrollbar(int orientation,int value,int visible,int minium,int maximum)
Correct Answer : T
Your Answer :
QuestionID : 10050 Subject Name Core Java
Q36. Which statement is true?
1. The compiler will fail to compile code that explicitely tries to call the
finalize() method
2. The finalize() method must be declared with protected accessibility
3. An overriding finalize() method in any class can always checked
exceptions
4. The finalize() method can be overloaded
Correct Answer : 4
Your Answer :
QuestionID : 10051 Subject Name Core Java
Q37. Which statement is true?
1. an obj will be garbage collected immediately after it becomes
unreachable.
2. If object obj1 is accessible from object obj2,and obj2 is accessible from
obj1,then obj1 and obj2 are not eligible for garbage collection
3. once an obj has become eligible for garbage collection,it will remain
eligible until it is destroyed
4. If obj1 can access obj2 that is eligible for garbage collection,then obj1
is also eligible for garbage collection
Correct Answer : 4
Your Answer :
QuestionID : 10062 Subject Name Core Java
Q38. class test
{
public static void main(String args[])
{
// char c = ` \u000A ` ;
}
}
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 13/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

1. Compilation Error
2. variable c will contain some value
3. c = `A`
4. None of above
Correct Answer : 1
Your Answer :
QuestionID : 10069 Subject Name Core Java
Q39. Every method of final class is implicitly final.
Correct Answer : T
Your Answer :
QuestionID : 10102 Subject Name Core Java
Q40. The major drawback of using native methods in java is that
your program will no longer be portable
Correct Answer : T
Your Answer :
QuestionID : 10149 Subject Name Core Java
Q41. What will be output of following

int tooSmall = Integer.MIN_VALUE - 1


1. 2147483647
2. -2147483648
3. Will give compile error
4. None of the above
Correct Answer : 1
Your Answer :
QuestionID : 10187 Subject Name Core Java
Q42. What is the diffrence between boolean logical operators and conditional
operator?
1. Both are same
2. Boolean logical operators evaluates both the operands whereas
conditional do not if the result can be determined from the left operand
3. Boolean logical operators can be applied to integral operands to
perform bitwise logical operations and conditional can not
4. both 2 & 3
Correct Answer : 4
Your Answer :
QuestionID : 10220 Subject Name Core Java
Q43. Which of these fields declarations are legal within
the body of an interface
a)public static int answer=100
b)int answer
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 14/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

c)final static int answer=100


d)private final static int answer=100
1. a,b
2. a,c
3. b,c
4. c,d
Correct Answer : 2
Your Answer :
QuestionID : 10241 Subject Name Core Java
Q44. System.gc() is a static method defined in System class to encourage
JVM
for garbage collection.
Correct Answer : T
Your Answer :
QuestionID : 10247 Subject Name Core Java
Q45. String str="hello";
String str1=str+"world";
str1=str1.intern();
String str2="helloworld";
if(str1==str2)
System.out.println("equal");
else
System.out.println("not equal");

1. compiler error
2. equal
3. not equal
4. exception is thrown
Correct Answer : 2
Your Answer :
QuestionID : 10445 Subject Name Core Java
Q46. RandomAccess is a marker interface used by List implementations to
indicate that they support fast random access.
Correct Answer : T
Your Answer :
QuestionID : 10460 Subject Name Core Java
Q47. ________ Class is Super class for all java exception classes
1. Throwable
2. Throw
3. ThrowsException
4. all
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 15/16
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

Correct Answer : 1
Your Answer :
QuestionID : 10461 Subject Name Core Java
Q48. Every Applate that u create must be a subclass of Applate
Correct Answer : T
Your Answer :
QuestionID : 10979 Subject Name Core Java
Q49. Which of the following method is used to create a thread?
1. run()
2. yield()
3. start()
4. create()
Correct Answer : 3
Your Answer :
QuestionID : 10982 Subject Name Core Java
Q50. Inserialization object is stored in form of?
1. byte
2. character
3. string
4. all
Correct Answer : 1
Your Answer :

file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/CoreJava/CoreJava_3.htm 16/16

You might also like