It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Some thoughts for the day! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Some thoughts for the day!" Watch "Some thoughts for the day!" New topic

Some thoughts for the day!

Hemal Mehta
Ranch Hand

Joined: Nov 16, 2000
Posts: 101
Just some thoughts for the day!!
a. An arithmentic operation always results in atleast a int being returned, even if the primitives are byte and short
b. A non abstract sub class always has to implement the abstract methods of the base class.
c. Base class X
Sub class Y
Allowed: Y myY=new X();
Not allowed: X myX=new Y();
d. Continue always takes the loop to the next iteration unlike break which totally comes out of the loop.
e. A base class may not be declared protected or private it is always public
f. Java keywords are always lowercase
Anyways more later...
Harpal Singh
Ranch Hand

Joined: Oct 10, 2000
Posts: 229
It is the other way round.........
Base class X
Sub class Y
Not Allowed: Y myY=new X();
Allowed: X myX=new Y();
Chk it out.........
Nakul Kasadwala

Joined: Oct 30, 2000
Posts: 22
Hello Hemant,

Always remeber one thing ,
Parent class object can hold object of child class.
public class ParentChildClass{
public static void main(String args[]){
ABC a = new XYZ();//line 1
XYZ x = new MNO();//line 2
a = new MNO();//line 3
x = new ABC();//line 4

class ABC{
int i;
class XYZ extends ABC{
int j;
class MNO extends XYZ{
int k;
Here ABC is parent class so it can hold object of child XYZ.
on line 4 it will throw following error:
"Incompatible type for =. Explicit cast needed to convert ABC to XYZ."
Since MNO is also sub class of ABC line 3 is correct.

I agree. Here's the link:
subject: Some thoughts for the day!
It's not a secret anymore!