Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Some thoughts for the day!

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hemal,Hemal,Hemal...
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.........
Harpal
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Hemant,

Always remeber one thing ,
Parent class object can hold object of child class.
e.g.
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.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic