PETER CARTER

Ranch Hand
+ Follow
since Aug 28, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by PETER CARTER

class A {
public String toString () {
return "4";
}
}
class B extends A {
public String toString () {
return super.toString() + "3";
}
}
public class test {
public static void main(String[] args) {
System.out.println(new B());
}
}
Compilation succeeds and 43 is printed.
But why ?
Thanks !!
Which two can directly cause a thread to stop executing? (Choose Two)
A. Exiting from a synchronized block.
B. Calling the wait method on an object.
C. Calling the notify method on an object.
D. Calling the notifyAll method on an object.
E. Calling the setPriority method on a thread object.
Answer: B, E
Why A is wrong ??
Thanks!!!
Which two declarations prevent the overriding of a method? (Choose Two)
A. Final void methoda() {}
B. Void final methoda() {}
C. Static void methoda() {}
D. Static final void methoda() {}
E. Final abstract void methoda() {}
Answer: A, D
I think all right!
Why?
But I mean :
If we choice B and E for 1,we should choice A and D for 2.
But it's wrong ,why ??
Thanks !!!
Help me in your heart !!
public class test1 {
void c(int i){
System.out.println("int");
}
void c(String s){
System.out.println("String");
}
public static void main(String[] args) {
test1 t=new test1();
char ch='p';
t.c(ch);
}
}
Why the result is :
int ??
Thanks!!
public class test {
public static void main(String[] args) {
int x=6;
System.out.println(~x);
}
}
Why print :-7 ??
Thanks!
Given the ActionEvent, which method allows you to identify the affected component?
A. GetClass.
B. GetTarget.
C. GetSource.
D. GetComponent.
E. GetTargetComponent.
Answer: C
I don't know what does A,B,C,D and E mean .
Thanks !!!
Which three are valid declarations of a float? (Choose Three)
A. Float foo = -1;
B. Float foo = 1.0;
C. Float foo = 42e1;
D. Float foo = 2.02f;
E. Float foo = 3.03d;
F. Float foo = 0x0123;
Answer: A, D, F
I think only D is right.
Do u follow me ??
Given:
1. public class MethodOver {
2. public void setVar (int a, int b, float c) {
3. }
4. }
Which two overload the setVar method? (Choose Two)
A. Private void setVar (int a, float c, int b) { }
B. Protected void setVar (int a, int b, float c) { }
C. Public int setVar (int a, float c, int b) (return a ; )
D. Public int setVar (int a, int b, float c) (return a ; )
E. Protected float setVar (int a, int b, float c) (return c ; )
Answer: A, C
I believe A,B,E are wrong because of Modifiers.
And I also believe C,D are wrong .I think "void" should instead of "int".
Thanks !!
[ September 22, 2004: Message edited by: Barry Gaunt ]
1:
public class Myclass
{
int x;
Myclass(int i){x = i;}

public static void main(String args[])
{
Myclass m1 = new Myclass(100);
Myclass m2 = new Myclass(100);

System.out.println(m1.equals(m2));
}
}
The result is :false .
Why ? I think it should be :true.
2:
public class test{
public static void main(String[] a){
String s1 = "amit";
String s3 = "arit";
String s4 = "arit";
String s2= s1.replace('m','r');
System.out.println(s2 == s3);
System.out.println(s3 == s4);
}
}
The answer is :
false
true
But I think it should be :false false.

Thanks !!
Use Thread.sleep(5000) instead of thread.sleep(5000)


Thanks !!