Angela Xia

+ Follow
since Jan 03, 2002
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Angela Xia

I want to show my appreciate to all of you. This morning, I passed SCJP2 with score 76%. Not so good, but to me, as a person started from ground zero, without any experience in programming, it is really amazing.
But I really belive that I would failed if your guys were not there,since all of you are so nice and always reply my posted questions promptly,that really helped me a lot.
Thanks again and good luck!
21 years ago
uestion ID :1003502809546
What will the following program print?
public class TestClass
static boolean b;
static int[] ia = new int[1];
static char ch;
static boolean[] ba = new boolean[1];
public static void main(String args[]) throws Exception
boolean x = false;
if( b )
x = ( ch == ia[ch]);
else x = ( ba[ch] = b );
System.out.println(x+" "+ba[ch]);
answer : false false
My question is: the index of an array should be int, so can char value be used in ba[ch] ? I chose the code will not compile because of this thinking. Thanks
Question ID :957621799662
Consider the following subclass definition:
public class SubClass extends SuperClass
int i, j, k;
public SubClass( int m, int n ) { i = m ; j = m ; } //1
public SubClass( int m ) { super(m ); } //2
Which of the following constructors MUST exist in SuperClass for SubClass to compile correctly?
The answer of this question is:
public SuperClass(int a)
public SuperClass()
I know the first one is absolutely right, but how about the second one? Since SubClass will not call the default constructor in SuperClass, it does it must exist in order to compile fine?
Here is the question from JQPlus
How many bytes will be written by the following code snippet in the file?
DataOutputStream dos=new DataOutputStream( new FileOutputStream("data"));
int x=0x12341234;
the answer is 9. why? Thanks!
Thank you so much and it really helps.
Given the following code, under which circumstances will the method return false?
public static boolean test(InputStream is) throws IOExecption{
int value;
return value==(value& 0xff);
Select all valid answers.
A) a character of more than 8 bits was read from the stream
B) An I/O error occurred.
C) Never
D) The end of the input was reached in the input stream
Answer is D.
As far as I know, the end of the input stream when reached by read, is -1, so return will be
-1==(-1&-1) that will return true, am I right?
Hi all,
Here is the question, and I have the question on its answer.
Given the following definition, which deficitions are valid?
interface I{
void setValue(int val);
int getValue();
Select all valid answers.
A) class A extends I{
int value;
void setValue(int val){value=val;}
int getValue(){ return value;}
B) interface B extend I{
void increment();}
C) abstract class C implements I {
int getValue(){ return 0;}
abstract void increment();}
D) interface D implements I{
void increment();}
E) class E implements I{
int value;
public void setValue(int val){ value=val;}
the right answer is b.
Although I know classes can not extend interface and they must implement them. interface can extend other interface. So the answer A & D are wrong. How to explain choice C and E? why they are wrong?
for the coding below:
class Check{
public class ICheck extends Check{
public static void main(String args[]){
Object o= new ICheck();
Check i= new ICheck();
Check c= new Check();
if (o instanceof XXX){
Select which of the following answers can be legally placed in the place if statement?
A) Object, ICheck only
B) Check , ICheck only
c) Object only
D) object,Check ,ICheck
the answer is D, why D but not C?
public class Star extends Object {
Star(String s1){
System.out.println(s1+"is a Star");}

Star(String s2, String s3){
System.out.println(s2+"and"+s3+" are also Stars");}

public static void main(String[] args){
Sun sun=new Sun();
Sun sun1=new Sun("Venus");
Sun sun2= new Sun("Mars", "Eaarth");
class Sun extends Star{
public Sun(){System.out.println("Star Wars1");
public Sun(String v1){ super(v1,"Saturn");
System.out.println("Star Wars2");}
public Sun (String v2, String v3){
if (v2.substring(0,v2.length()).length()>v3.length())
System.out.println("Mission to Mars");
For the above code, the answer of compiling the code will be:
1. Star
2.Star Wars1
3.Mercury is a star
4.Venus and Saturn are also star
5.Star Wars2
7. Earth
My question is, when compile the third constructor in subclass Sun, Sun sun2= new Sun("Mars", "Earth"); why the line 6 Star get print out?
Thanks for attention