• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thanks everyone.

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am the one who was not sure if shift signs were covered and what '&' meant a couple of hours before the exam.

Fortunately, I passed with 63%. Thanks Andres Gonzalez, Marcus
Green, Hanna Habashy, Dhanashree M, and Chi Lin for answering my
questions promptly. Also thanks everyone's input on this forum.
I think I under-estimated the difficulty of the exam. Or at least I
got the questions that happened to be tough.
Within the first 12 questions, almost everyone was related to
Thread, at least 6 of them were appeared in a row. I was even
wondering they gave me the wrong exam that might named "Sun
Certified Thread Programmer". For those of you who have not taken
the exam, I strongly recommend you to practice on this topic more
and understand the "monitor", "synchronized", and "mutually exclusive
lock" concepts.
I also saw lots of code that I'd never seen before. However, it is too late to know that
for(int i =0; i<5; System.out.println(i))
{ i++; }
compiles and runs
One hour before the exam, I was suddenly puzzled by the following
code when I was playing with polymorphism. I wasn't able to fully understand the results before taking the exam. Luckily, I did not meet such kind of questions. Below are my unsolved question:
/****************File Test.java**************************/
class A
{
public void amethod(A a) { System.out.println("A");}
}
class B extends A
{
public void amethod(B b) { System.out.println("B");}
}
class C extends B
{
public void amethod(C c) { System.out.println("C");}
}
public class Test
{
public static void main(String args[])
{
A a = new A();
B b = new B();
C c = new C();
A c2 = new C();
c2.amethod(a);
c2.amethod(b);
c2.amethod(c);
}
}
/*****************File Test2.java************************/
class A
{
public void amethod() { System.out.println("A");}
}
class B extends A
{
public void amethod() { System.out.println("B");}
}
class C extends B
{
public void amethod() { System.out.println("C");}
}
public class Test2
{
public static void main(String args[])
{
A a = new A();
B b = new B();
C c = new C();
A c2 = new C();
c2.amethod();
c2.amethod();
c2.amethod();
}
}
If you compile the code, you will see that Test.class outputs AAA while Test2.class outputs CCC. I don't quite get it. Can anyone give me a hand?
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congratulations Yingie !!! . Back to work

This is a trick question. You might think that's overriding, but in fact amethod() is overloaded (notice the parameter types are different).
So, when it's overloading, it's based on the reference type, not the object type:
A c2 = new C();
so when you use
c2.amethod(a);
c2.amethod(b);
c2.amethod(c);
they're all refering to class A.
Second code:

Notice the method amethod(). Now it is overriding (same parameter type -in this case none-, all public (must not be more restrictive in subclass), same return type, same method name, etc.)
So, when it's overriding, it's based on the object type, not the reference type:
A c2 = new C();
Therefore, the method invoked is from class C.
hope it helps and congrats again..
Did you get any questions on shifting bits?
[ August 29, 2003: Message edited by: Andres Gonzalez ]
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW,
for(int i =0; i<5; System.out.println(i))
{ i++; }
for(first ; second ; third)
third can be anything. It is the last statement that your loop is going to execute. It is widely used for increments, but you can put any statement you want.

it'll print "test" 5 times.
 
Ranch Hand
Posts: 443
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or to save a few lines, you can also do it this way:
for(int i =0; i<5; System.out.println(i),i++);
for(int i =0; i<5; System.out.println("test"),i++);
[ August 30, 2003: Message edited by: Alton Hernandez ]
 
Yingie Pitts
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


when it's overloading, it's based on the reference type, not the object type...
when it's overriding, it's based on the object type, not the reference type...


Execellent! Now I got the key. Thanks.
I only met one question related to shifting bits. It was asking you to choose two out of five expressions that can be evaluated to the same result. Only one of the expressions contained '<<' sign. I think that is it. (Sorry I can not explicitly tell you the question because of the exam policy)
Have fun,
Yingie
 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congratulation Yingi
Well done
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congratulations, Yingie - the first Sun Certified Thread Programmer SCTP.
Thank you for telling us about your experience.
[ September 01, 2003: Message edited by: Marlene Miller ]
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nicely done -
but I'm moving this to the Sun Certification Results forum. Please continue the congratulations there.
 
Does this tiny ad smell okay to you?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic