• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Regarding Strange Output.

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I executed the following java code, which was not showing proper output in my perspective. Kindly correct me if i am wrong in understanding the concept behind that.

The Java Code :




My Doubt Is: Why the following text is not part of the OUTPUT.
Initialization Block1 Inside class-->Interface_Ex2
Initialization Block2 Inside class-->Interface_Ex2


Thanks In Advance.

Regards,
Potluri
 
V. Potluri
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello EveryBody,





My Doubt Is Why The Output Doesn't Contain The Following Text Which Is The
Part Of INITIALIZATION BLOCKS.

Initialization Block1 Inside class-->Interface_Ex2
Initialization Block1 Inside class-->Interface_Ex2



Thanks In Advance.

Regards,
Potluri.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason is that there is no instance of *class* Interface_Ex2(wow the class name starts with Interface ... so misleading for a causal reader like me ) created in the main() method.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that's because you don't initialize the Interface_Ex2 object instance
 
Max Ma
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you could add the line:Interface_Ex2 ie = new Interface_Ex2(); following
GrandMother obj = new GrandMother();
obj.grandFatherName();
obj.grandMotherName();
obj.fatherName();
obj.motherName();
obj.childName();

you will see that two lines appear at the end
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Max,
I think those two lines will be added after 2nd line of the previous output.Please correct me if I am wrong
Thanks
 
Max Ma
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it depends on where you create that object
 
V. Potluri
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Max,

I tested the code. what you said is correct. The output is depend the place where we create the object of Interface_Ex2. Thanks for your precious time for giving the answer. Have a very nice and happy day.

With Best Wishes,
Potluri
 
expectation is the root of all heartache - shakespeare. tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic