JAVA DUMPS 1(SCJP)

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.

Answer: A



QUESTION NO: 2


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};


Answer: A, B


QUESTION NO: 3

Given:

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


Answer: D


QUESTION NO: 4


Given:

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.


Answer: E


5 comments:

Dileep Malayanur said...

Hi,
I run an blog called Start Solutions I wish we could have an mutual exchange of knowledge and traffic :-)

Anonymous said...

Hey there! I just wish to offer you a big thumbs up for
the great info you have got right here on this post.
I am coming back to your blog for more soon.

Feel free to surf to my site calorie burn calculator

Anonymous said...

Good Work.
I have suggestion: create the the format where only question is visible and not the answer but collective answer's can be put in the last. This way reader can actually think for answers before jumping to direct answers.

Anonymous said...

Your means of describing all in this post is really good, all
be able to easily understand it, Thanks a lot.

My web site ::

Anonymous said...

It's a shame you don't have a donate button! I'd definitely donate to this fantastic blog!

I suppose for now i'll settle for bookmarking and
adding your RSS feed to my Google account. I look forward to
new updates and will talk about this site with my Facebook group.
Talk soon!

Also visit my webpage: http://softeclipse.com/adobe-reader/ ()

Post a Comment