Angela Xia

Greenhorn
+ Follow
since Jan 03, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
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;
dos.writeByte(x);
dos.writeChar(x);
dos.writeShort(x);
dos.writeInt(x);
dos.close();
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 =is.read();
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?
Thanks
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?
Thanks
for the coding below:
class Check{
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){
System.out.println("True");
}
}
}
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?
Thanks
public class Star extends Object {
Star(){
System.out.println("Star");
}
Star(String s1){
super();
System.out.println(s1+"is a Star");}

Star(String s2, String s3){
this("Mervury");
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");
else
System.out.println("Earth");
}
}
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
6.Star
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