• 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

How is code executed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




Answer
third second first snootchy 420
 
Ranch Hand
Posts: 83
Netbeans IDE MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello rancher,

please ask specific question.... where you stuck don't ask full answer.... you harm yourself by asking full answer... let your brain think

Hint : we can call constructor from another constructor...
 
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
When the code gets executed,it goes to default constructor i.e. it goes to Line 5 there 'this' is called it means it goes to corresponding super class.
 
vinayak jog
Ranch Hand
Posts: 83
Netbeans IDE MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

madhuri kunchala wrote:Hi,
When the code gets executed,it goes to default constructor i.e. it goes to Line 5 there 'this' is called it means it goes to corresponding super class.



how can this means super class ?? and also he is not extending any class please dont mis guide

 
Ranch Hand
Posts: 49
Java ME PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we call "this" to current executing object.yep we can call constructor from another constructor.
then it goes according to the constructor calling chain
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bootchy b = new Bootchy();

In the main function we are creating the new object by calling constructor with no argument. So control reaches at line number 5. In this method we are specifically calling different constructor(with argument) of the same object. So the control reaches at line number 10. Similar thing is happening in constructor with one argument.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

madhuri kunchala wrote:Hi,
When the code gets executed,it goes to default constructor . . .

What default constructor? The Bootchy class doesn't have a default constructor. java.lang.Object might have, but there is no default constructor here. Line 5 is not a default constructor, but a no-arguments constructor with an implemented body. The two are very different.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your constructor is the same name you used as the head name of the file.
 
Ranch Hand
Posts: 326
Android Mac OS X Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:What default constructor? The Bootchy class doesn't have a default constructor. java.lang.Object might have, but there is no default constructor here. Line 5 is not a default constructor, but a no-arguments constructor with an implemented body. The two are very different.



Yes Campbell, as usual you are technically correct (according to section 8.8.9 of Java Specification). But both you and me, and quite a lot of other people also knows that the term “default constructor” may additionally refer to a constructor that may be called without arguments.

Outside of the academic world, it is easier to tell a programmer "you need to create a default constructor" instead of saying "you need to create a no-argument constructor".

So, from a beginners point of view, how would you explain the difference between:



that is a default constructor per definition and



that is not?
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is just as easy to use correct terminology. There are enough people out there using wrong terminology. The reason for jargon is that it can be made precise. Saying "default" when yo umean "no arguments" reduces the value of our specialised language.
And your example is not actually "a default constructor per definition", but has exactly the same effect.
 
Ove Lindström
Ranch Hand
Posts: 326
Android Mac OS X Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
-- nevermind --
 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic