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

java (3)

The document contains a series of multiple-choice questions and answers related to Core Java, along with the user's responses and the correct answers. The user scored 24 out of a possible score based on their answers to various questions. Each question covers different aspects of Java programming, including concepts like method overriding, exception handling, and object references.

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)
2 views

java (3)

The document contains a series of multiple-choice questions and answers related to Core Java, along with the user's responses and the correct answers. The user scored 24 out of a possible score based on their answers to various questions. Each question covers different aspects of Java programming, including concepts like method overriding, exception handling, and object references.

Uploaded by

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

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

Close this Window Hi dac35, You have scored : 24


QuestionID : 1197 Subject Name Core Java
Q1. Which of the following lines will not compile?
1. byte b1 = 5, b2 = 3, b3;
2. short s = 25;
3. b2 = s;
4. b3 = b1 * b2;
1. Line 1 and Line 3
2. Line 4 only
3. Line 3 and Line 4
4. Line 1 only
Correct Answer : 3
Your Answer : 3
QuestionID : 1210 Subject Name Core Java
Q2. What will be the output of the following program?
class Main1{
public static void main(String args[]){
boolean b = true;
System.out.println("XXX");
return;
System.out.println("YYY");}}
1. XXX
2. YYY
3. XXX followed by YYY
4. Error. Won`t compile
Correct Answer : 4
Your Answer : 1
QuestionID : 1232 Subject Name Core Java
Q3. Which of the following represent(s) a hexadecimal number?
1. 570
2. (hex) 5
3. 0x9F
4. 05
Correct Answer : 3
Your Answer : 3
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 1/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

QuestionID : 1255 Subject Name Core Java


Q4. Declarations can appear anywhere in the body of a Java method.
Correct Answer : T
Your Answer : T
QuestionID : 1274 Subject Name Core Java
Q5. Any method in super class can be overridden in its subclass.
Correct Answer : F
Your Answer : T
QuestionID : 1278 Subject Name Core Java
Q6. A method declared as static cannot access non-static class members.
Correct Answer : T
Your Answer : T
QuestionID : 1373 Subject Name Core Java
Q7. A JPanel may not contain another JPanel.
Correct Answer : F
Your Answer : T
QuestionID : 9300 Subject Name Core Java
Q8. Objects are not garbage collected as long as there is atleast
one reference to them
Correct Answer : T
Your Answer : T
QuestionID : 9312 Subject Name Core Java
Q9. 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 : 0
QuestionID : 9317 Subject Name Core Java
Q10. Read the following code carefully
public class AStringQuestion
{
static String s1;
static String s2;
public static void main(String args[])
{
s2=s1+s2;
System.out.println(s2);
}
}
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 2/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

1. Compilation Error
2. Run time Exception -NullPointer Exception in the second line of main
method
3. Will print nullnull on the screen
4. print an empty line on screen
Correct Answer : 3
Your Answer : 2
QuestionID : 9319 Subject Name Core Java
Q11. Objects are always passed by _______.
1. Value
2. Reference
3. Either Value Or Reference
4. Using Pointers
Correct Answer : 2
Your Answer : 2
QuestionID : 9326 Subject Name Core Java
Q12. if("string".trim()=="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 compiler error
4. none
Correct Answer : 1
Your Answer : 2
QuestionID : 9333 Subject Name Core Java
Q13. Which of these field declarations are legal within the body
of an interface?
select the correct answers.
1. public static int answer=42;
2. private final static int answer=42;
3. final static int answer =42;
4. all of the above
Correct Answer : 4
Your Answer : 1
QuestionID : 9451 Subject Name Core Java
Q14. Attribute of an Object is also known as its ________.
1. state
2. method
3. behavior
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 3/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

4. procedures
Correct Answer : 1
Your Answer : 1
QuestionID : 9473 Subject Name Core Java
Q15. Read the following code carefully
public abstract class AbstractClass
{
public AbstractClass()
{
System.out.println("this is an abstract class constructor");
}
public void amethod()
{
System.out.println("This is in the method in the abstract class");
}
}
1. Compiler error-abstract classes cannot have constructors.
2. Compiler error-the method AbstractClass does not have a valid return
type.
3. Compiler error-the class is pracically not an abstract class as it does not
have any unimplementd methods.
4. No compiler error-the class cannot be instantiated directly.It has to be
extended to an non-abstract class.The constructors of the extended class will
call the constructor of the abstract class.
Correct Answer : 4
Your Answer : 4
QuestionID : 9478 Subject Name Core Java
Q16. give the following source code, which comment line can be
uncommented without introducing errors ?
abstract class MyClass {
abstract void f();
final void g() {}
// final void h() {} // (1)
protected static int i ;
private int j;
}
final class MyOtherClass extends MyClass {
// MyOtherClass(int n) { m = n } //(2)

public static void main (string[] args) {


MyClass mc = new MyClass();
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 4/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

}
void f() {}
void h() {}
// void k() { i++ ; } //(3)

// void l() { j++ ; } //(4)


int m;
}
1. final void h() {} // (1)
2. MyOtherClass(int n) { m = n } //(2)
3. void k() { i++ ; } //(3)
4. void l() { j++ ; } //(4)

Correct Answer : 3
Your Answer : 0
QuestionID : 9537 Subject Name Core Java
Q17. Given the following code within a method, which statement is true?

int a,b;
b=5;

a. Local variable a is not declared.


b. Local variable b is not declared.
c. Local variable a is declared but not initialised.
d. Local variable b is declared but not initialised.
e. Local variable b is initialised but not declared.

1. a & b
2. c & d both
3. a,d,e
4. c only
Correct Answer : 4
Your Answer : 4
QuestionID : 9552 Subject Name Core Java
Q18. Name the Collection interface implemented by the hash set class
1. Hash Set
2. Set
3. Hash
4. List
Correct Answer : 2
Your Answer : 2
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 5/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

QuestionID : 9573 Subject Name Core Java


Q19. public class AQuestion
{
public static void main(String args[])
{
System.out.println("Before try");
try
{
}
catch(Throwable t)
{
System.out.println("inside catch");
}
System.out.println("at the end");
}
}
1. Compiler error-Throwable object can not be thrown
2. Compiler error-Throwable object can not be caught only exception
must be caught.
3. no error-the lines Before try and at the end are printed on screen.
4. none of above
Correct Answer : 3
Your Answer : 3
QuestionID : 9639 Subject Name Core Java
Q20. what will the result of attempting to compile and run the following prog.
public class myclass
{
public static void main(String args[])
{
String a,b,c;
c=new String("mouse");
a=new String("cat");
b=a;
a=new String("dog");
c=b;
System.out.println(c);
}
}
select the one answer
1. the program will fail to compile
2. the program will print mouse when run
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 6/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

3. the program will print cat when run


4. the program will print dog when run
Correct Answer : 3
Your Answer : 3
QuestionID : 9673 Subject Name Core Java
Q21. Java compiler stores the .class files in the path specified in
CLASSPATH environmental variable
Correct Answer : F
Your Answer : F
QuestionID : 9684 Subject Name Core Java
Q22. A double value can be typecasted to byte.
Correct Answer : F
Your Answer : F
QuestionID : 9701 Subject Name Core Java
Q23. What statement is true?
1. String Objects are immutable.
2. subclass of the String class can be mutable
3. StringBuffer class objects are immutable
4. both (1) & (3)
Correct Answer : 1
Your Answer : 1
QuestionID : 9705 Subject Name Core Java
Q24. Read the piece of code carefully

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. compiler will cause an error
4. none of the above
Correct Answer : 1
Your Answer : 3
QuestionID : 9708 Subject Name Core Java
Q25. public class Q10
{
public static void main(String [] args)
{
int i=10;
int j=10;
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 7/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

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 : 1
QuestionID : 9782 Subject Name Core Java
Q26. You need to create a class that will store unique object elements.
you do not need to sort these elements but they must be unique.
what interface might be most suitable to meet this need?
1. set
2. list
3. map
4. vector
Correct Answer : 1
Your Answer : 3
QuestionID : 9790 Subject Name Core Java
Q27. What will happen to Exception object after exception handling.
1. Nothing
2. At times it may get garbage collected
3. it always get garbage collected
4. none of the above
Correct Answer : 2
Your Answer : 1
QuestionID : 9816 Subject Name Core Java
Q28. Given the following class definitions, which expression identifies
whether the
object referred to by obj was created by instatiating class B rather
than classes A,C, and D?

class A{}
class B extends A{}
class C extends B()
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 8/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

class D extends A()

select the one correct answer.


1. obj instanceof B.
2. obj instanceof A && !(onj instanceof C)
3. obj instanceof B && !(onj instanceof C)
4. !(obj instanceof C || obj instanceof D)
Correct Answer : 3
Your Answer : 1
QuestionID : 9910 Subject Name Core Java
Q29. If an exception is thrown in the try block and it is not handled
in the catch block then the exception will be sent to the default
exception handler.
Correct Answer : T
Your Answer : F
QuestionID : 9970 Subject Name Core Java
Q30. Using System.exit(1); in try block will not allow finally code to execute.
Correct Answer : T
Your Answer : F
QuestionID : 10009 Subject Name Core Java
Q31. It is perfectly legal to assign an object of a super class to a subclass
reference without a cast
Correct Answer : F
Your Answer : F
QuestionID : 10036 Subject Name Core Java
Q32. The GridBagConstraints Class
1. is serializable
2. is clonable
3. belong to the java.awt.package
4. all the above
Correct Answer : 1
Your Answer : 4
QuestionID : 10113 Subject Name Core Java
Q33. What is the result of executing the following code, using the parameters
4 and 0:

public void divide(int a, int b) {

try {
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 9/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

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 : 1
QuestionID : 10119 Subject Name Core Java
Q34. What is the result of executing the following code when the value of x
is 2:

switch (x) {

case 1:

System.out.println(1);

case 2:

case 3:

System.out.println(3);

case 4:

System.out.println(4);

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

1. Nothing is printed out


2. The value 3 is printed out
3. The values 3 and 4 are printed out
4. The values 1, 3 and 4 are printed out
Correct Answer : 3
Your Answer : 4
QuestionID : 10205 Subject Name Core Java
Q35. The unintialized final parameter is called as -------variable
1. uninitialized
2. final
3. blank final
4. none of above
Correct Answer : 3
Your Answer : 4
QuestionID : 10241 Subject Name Core Java
Q36. System.gc() is a static method defined in System class to encourage
JVM
for garbage collection.
Correct Answer : T
Your Answer : T
QuestionID : 10248 Subject Name Core Java
Q37. class A
{
public static void main(String[] args)
{
String str="ram-shyam";
System.out.println(str.substring(4,10));
}
}

what will be output


1. shyam
2. Ram
3. Compile time error
4. Runtime error
Correct Answer : 4
Your Answer : 1
QuestionID : 10264 Subject Name Core Java
Q38. What will be the output if following programme is run -> java
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 11/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

ReturnDemo 1 2 3 4
public class ReturnDemo
{
public static void main(String[] args)
{
if(checkValue(args.length)>3)
System.out.println("Hello World!");
return;//Line x
}
static int checkValue(int i)
{
if(i>3)
return i;
else
return 2.0;//line y
}
}
1. Hello world!
2. Compile time error on line x
3. Compile time error on line y
4. Both 2 and 3
Correct Answer : 2
Your Answer : 1
QuestionID : 10281 Subject Name Core Java
Q39. What is the correct ordering for the import, class and package
declarations when found in a single file?
1. package, import, class
2. class, import, package
3. import, package, class
4. package, class, import
Correct Answer : 1
Your Answer : 1
QuestionID : 10487 Subject Name Core Java
Q40. To create the TCP-IP stream transport layer is responsibe
Correct Answer : F
Your Answer : T
QuestionID : 10495 Subject Name Core Java
Q41. getCause() are methods of which class.
1. Throwable
2. IOException
3. RunTimeException
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 12/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

4. none of the above


Correct Answer : 1
Your Answer : 1
QuestionID : 10497 Subject Name Core Java
Q42. which of the folowing classes have getName() method.
1. Field
2. Method
3. Constructor
4. all of the above.
Correct Answer : 4
Your Answer : 4
QuestionID : 10503 Subject Name Core Java
Q43. int a = 27;
{
int a = 30;
System.out.println(a);
}

output is :
1. 30
2. 27
3. compile time error Variable a is already declared
4. none of the above
Correct Answer : 1
Your Answer : 1
QuestionID : 10504 Subject Name Core Java
Q44. in _______ , everything is undefined
1. interface
2. abstract class
3. final class
4. none of the above
Correct Answer : 1
Your Answer : 4
QuestionID : 10511 Subject Name Core Java
Q45. Enumarator has method to remove method to remove elements.
Correct Answer : F
Your Answer : F
QuestionID : 10976 Subject Name Core Java
Q46. What will be the result of compiling and running the given program?
Select one correct answer.
1 class Q
file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 13/14
12/14/2018 Result:- SunBeam Infotech Pvt LTD, Pune

2{
3 public static void main(String args[])
4{
5 System.out.println(Math.abs(-2147483648));
6}
7}
1. Program compiles correctly and prints 2147483648 when executed.
2. Program compiles correctly and prints -2147483648 when executed.
3. Program compiles correctly and prints 2147483647 when executed.
4. The program will not compile.
Correct Answer : 2
Your Answer : 0
QuestionID : 11004 Subject Name Core Java
Q47. Dictinary is a class of java.util package
Correct Answer : T
Your Answer : F
QuestionID : 11017 Subject Name Core Java
Q48. Which is not an interface
1. Blob
2. SavePoint
3. Struct
4. None of the above
Correct Answer : 4
Your Answer : 3
QuestionID : 11019 Subject Name Core Java
Q49. When an applet begins awt call following sequence of method.
1. init(),paint(),destroy
2. init(),start(),paint(),stop(),destroy
3. init(),service(),destroy
4. init(),start(),stop(),destroy
Correct Answer : 2
Your Answer : 1
QuestionID : 11044 Subject Name Core Java
Q50. When we create object of outer class the object of inner class is
automaticaly created.
Correct Answer : F
Your Answer : F

file:///D:/STUDY%20MATERIAL/sample%20paper/cdac%20dumps/cdac%20dumps/imp_multiple_question/imp%20multiple%20question/Mix/java.htm 14/14

You might also like