COREJAVA

COREJAVA Objective Questions And Answers


Totel:43 Click: 1 2 3 4 5 6 7 8 9
Java Interview Questions And Answers

Page 1

Questions Show Answers Total Posts Post Your Answers Last Post
Given:
1. public class Test {
2. public static void main(String args[]) {
3. class Foo {
4. public int i = 3;
5. }
6. Object o = (Object)new Foo();
7. Foo foo = (Foo)o;
8. System.out.println("i = " + foo.i);
9. }
10. }
What is the result?
A. i = 3
B. Compilation fails.
C. A ClassCastException is thrown at line 6.
D. A ClassCastException is thrown at line 7.
Show Answers 3 Post Your Answers 2021-08-19 00:00:00
Tolaram Ghosh
Which two cause a compiler
error? (Choose two)
A. float[] = new float(3);
B. float f2[] = new float[];
C. float[] f1 = new float[3];
D. float f3[] = new float[3];
E. float f5[] = { 1.0f, 2.0f, 2.0f };
F. float f4[] = new float[] { 1.0f. 2.0f. 3.0f};
Show Answers 1 Post Your Answers 2012-03-10 00:00:00
Rajesh Kumar
1. class Test {
2. private Demo d;
3. void start() {
4. d = new Demo();
5. this.takeDemo(d);
6. }
7.
8. void takeDemo(Demo demo) {
9. demo = null;
10. demo = new Demo();
11. }
12. }
When is the Demo object, created on line 3, eligible for garbage collection?
A. After line 5.
B. After line 9.
C. After the start() method completes.
D. When the takeDemo() method completes.
E. When the instance running this code is made eligible for garbage collection.
Show Answers 1 Post Your Answers 2012-03-10 00:00:00
Vikas
11. int i =1,j =10;
12. do {
13. if(i++> --j) {
14. continue;
15. }
16. } while (i <5);
17. System.out.println("i = " +i+ "and j = "+j);
What is the result?
A. i = 6 and j = 5
B. i = 5 and j = 5
C. i = 6 and j = 5
D. i = 5 and j = 6
E. i = 6 and j = 6
Show Answers 1 Post Your Answers 2012-03-10 00:00:00
Sudha
Which statement is true about assertion in the Java programming language?
A. Assertion expressions should not contain side effects.
B. Assertion expression values can be any primitive type.
C. Assertion should be used for enforcing preconditions on public methods.
D. An AssertionError thrown as a result of a failed assertion should always be handled by the enclosing method.
Show Answers 1 Post Your Answers 2012-03-10 00:00:00
Sujata

Goto Page:

Java Interview Questions And Answers

Java Interview Questions And Answers


Java Interview Questions And Answers

Java Subjective Questions And Answers


R4R,Java Objective fresher and experienced, Java Subjective fresher and experienced ,Java Interview Questions And Answers,Java fresher and experienced,Java Interview fresher and experienced ,Java Questions fresher and experienced,Java Answers fresher and experienced