Friday, September 4, 2009

SCJP Questions

1 public class Foo {
2 public static void main (String [] args) {
3 StringBuffer a = new StringBuffer ("A");
4 StringBuffer b = new StringBuffer ("B");
5 operate (a,b);
6 system.out.printIn{a + "," +b};
7 )
8 static void operate (StringBuffer x, StringBuffer y) {
9 x.append {y};
10 y = x;
11 )
12 }
What is the result?
A. The code compiles and prints "A,B".
B. The code compiles and prints "A,A".
C. The code compiles and prints "B,B".
D. The code compiles and prints "AB,B".
E. The code compiles and prints "AB,AB".
F. The code does not compile because "+" cannot be overloaded for StringBuffer.
Answer: D

0 comments:

Post a Comment

 

About

Site Info

Information Source

Academy of JAVA by Rajesh Rolen Copyright © 2009 Community is Developed by Rajesh Kumar Rolen WebSite

/* tracking code by yahoo login */