Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!

Yi Dong

Greenhorn
+ Follow
since May 19, 2003
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 Yi Dong

Hi Everybody:
Can anyone tell where I can the answers for Barry Boones's Mock Exam?
Thanks in advance!
Yi
Hi Everyone:
The question is:
Given the following class definition which of the following can be legally placed after the comment line
//Here ?

1)MyOver m = new MyOver();
2)super();
3)this("Hello",10);
4)Base b = new Base(10);
The answer is 4)
Can anybody explain why 1) is not correct?
Thanks in advance!
Yi

(added code brackets - I luv 'em)
[ April 23, 2004: Message edited by: Barry Gaunt ]
Hi Everybody:
Here is the question: the correct ans is 1, Somebody please explain why.
Thanks in advance !
Yi Dong
Question 196)
Read the code below carefully.
import com.abhilash.abhilash;
public class One
{
public static void main()
{
abhilash a = new abhilash();
}
}
1.The code will fail to compile. The class com.abhilash.abhilash can never be imported.
2.The code will compile. Runtime error occurs if one of the class in the 3.import does not exist and is referenced.
4.The code will compile and run with out any problem.
Hi All:
Here is the question:
Which of the following statements about threading are true
1) You can only obtain a mutually exclusive lock on methods in a class that extends Thread or implements runnable
2) You can obtain a mutually exclusive lock on any object
3) A thread can obtain a mutually exclusive lock on a method declared with the keyword synchronized
4) Thread scheduling algorithms are platform dependent
I think only 2, 4 are correct, but the ans are 2, 3, 4.
Is there any lock on a method ? Can somebody explain this ?
Thanks in advance !
Yi Dong
Hi Carl:
What is MANNING exam study kit? Is it a book? what is the whole title of it ?
Thanks Yi Dong
18 years ago
Hi Guys:
Thanks you very much for your explanation!
Yi Dong
The question is:
Which of the following statements are true?
1) All of the variables in an interface are implicitly static
2) All of the variables in an interface are implicitly final
3) All of the methods in an interface are implicitly abstract
4) A method in an interface can access class level variables
Can anybody explain why 4) is not right?
Thanks in advance!
Yi Dong
Hi Anish:
The error is:
ADirtyOne.java:4: unclosed character literal
}
ADirtyOne.java:4:<identifier>expected
}
Yi Dong
Question 28.
public class ADirtyOne
{
//char a = '\u000A';
}
An attempt to compile the above class
1. will complete successfully.
2. will compile sucessfully but with a warning message.
3. will not compile - complains on an invalid expression.
why the code can not be comnpiled, I thought // is commenting out that line of code, but when I try to compiled it, the compiler gave me an error.
Thanks in advance !
hi everybody:
I am doing Valentin's mock, but after I submit my answer, it said the page can not be displayed. What do I need to do to check my answer ?
Thanks in advance!
Yi
Hi Everyone:
I just finished Barry Boone's 70 mock questions, but when I clicked on the answer, it could not find the page, is anybody know where I can find the answers for the 70 questions ?
Thanks in advance !
Yi Dong
The question is:
class ColorException extends Exception {}
class WhiteException extends ColorException {}
abstract class Color {
abstract void m1() throws ColorException;
}
class White extends Color {
void m1() throws WhiteException {throw new WhiteException();}
public static void main (String[] args) {
White white = new White();
int a,b,c,d;
a = b = c = 0;
try {
white.m1();
a++;
} catch (WhiteException e) {b++;}
finally {c++;}
System.out.print(a+","+b+","+c);
}
}
I thought a++ would never be reached, so there should be a compile-time error code not reachable, but it compiled fine. Can anybody explain to me why there is no such error, can a++ ever be reached ?
Thanks in advance
Yi
I came across a question :
import java.io.*;
public class TechnoSample
{
public static void main(String[] args)
{
TechnoSampleSub myref = new TechnoSampleSub();
try
{
myref.test();
}
catch(IOException ioe){}
}

void test() throws IOException
{
System.out.println("In TechnoSample");
throw new IOException();
}
}
class TechnoSampleSub extends TechnoSample
{
void test()
{
System.out.println("In TechnoSampleSub");
}
}
When I compiled this , it gave me a compile-time error, but after I changed all IOException in the three places to Exception, it compiled and ran.
I know that when there was a compile error, it is due to the test() method in the subclass never throws a IOException, but I think after changed to Exception, the problem was still in existence.
Thanks Yi
Since ArithmeticException is Runtime exception, it is not the checked exception. so d) is not declaring new checked exception.
33. Consider the classes defined below:
import java.io.*;
class Super
{
int methodOne( int a, long b ) throws IOException
{ // code that performs some calculations
}
float methodTwo( char a, int b )
{ // code that performs other calculations
}
}
public class Sub extends Super
{
}
Which of the following are legal method declarations to add to the class Sub? Assume that each method is the only one being added.
a) public static void main( String args[] ){}
b) float methodTwo(){}
c) long methodOne( int c, long d ){}
d) int methodOne( int c, long d ) throws ArithmeticException{}
e) int methodOne( int c, long d ) throws FileNotFoundException{}
I chose a), b), d), e)
but the answer is a, b, e without d
Anybody know the reason ?
Thanks in advance !