• 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

Compiletime vs. Runtime

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anyone pls tell what type of checks are done in java at compile time?I mean what kind of errors are detected at compile time?And what type of errors are taken care of at runtime?
What do we use exceptions and Assertions for?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Java In General (Beginner)...
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At compile time , references are checked , but at run time actuall objects are checked .

here is an example .

class A
{
A()
{ }
}
class B extends A
{
}
class C extends A
{
}

class D
{
public static void main(String[] arg)
{
A a = new C();
B b = ( B ) a ;
}
in this at run time th reference are only checked , since a is typecasted , shows no error at compile time , but at run time u r objects are created , and C's object is getting assigned to B's reference , hence fails at run time .

As a simple rule , at compile time th reference are checked , actual object are created at run time .
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic