• 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

No Output

 
Greenhorn
Posts: 7
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I copied this code from a tutorial on Inheritance which they show with an OUTPUT but when I run it with no error red flags it doesn't produce anything, why?



Output:
Base Class Method
Derived Class Method
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I copied your code and got exactly the output you said you expected to see. How did you run the code?
Please tell us where such code comes from; I am finding it difficult to see the point of that exercise. Maybe seeing the original will help.
 
Willie Busigo
Greenhorn
Posts: 7
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Program Example:


Output:

The original source came from the website called, "mygreatlearning.com/blog/inheritance-in-java." I copy/pasted the code from the site. "Inheritance in Java and types of Inheritance in Java".
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the link; that tutorial is neither good nor bad, but it doesn't explain things like the “IS‑A” relationship, so I think it probably won't help you,.
Please show how you are running your code, so we can see why you are getting no output.
I see you have greatly improved the code formatting from the tutorial
 
Willie Busigo
Greenhorn
Posts: 7
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Eclipse.  
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And how are you running the program? Where are you looking for the output?
 
Willie Busigo
Greenhorn
Posts: 7
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If by how you mean what editor, I'm using Eclipse and I'm looking for the output in the console, If not then please define, "How are you looking and where"?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start with a simple program like "Hello World" (it just has a main method which writes "Hello World" to the console) and see what happens when you run it.

If you see no output in the place where you're looking, then either you aren't looking at the console or you didn't run the program.
 
Willie Busigo
Greenhorn
Posts: 7
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I admit I'm only in the first grade when it comes to programming but I've been at this for a little while now albeit I have a long way to go however I've managed to run Hello World and a few other programs in many different tutorials using java, javascript and c++ without a problem in both Eclipse and VS Code. Like I said  first grade stuff. No big deal. I'll just move on gaining more skills until and if I solve the issue, thanks. Sometimes the problem is right in front of me and I may not be seeing it.
 
Willie Busigo
Greenhorn
Posts: 7
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
P.S. Did you run the program and did you get the out put?
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's in my first post in this thread.
Don't try moving on to difficult things and leaving the easy things not working. You are risking getting yourself completely confused like that.
 
Willie Busigo
Greenhorn
Posts: 7
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree, I tend to start my studies from the beginning but recently, by that a mean as of today, I think I getting a better handle on the basics. I'm using a website called, w3schools.com and I starting to put the concept together as a result of the Lessons and Exercise format they use.  
 
Bartender
Posts: 1737
63
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just my two cents.

I personally find it very hard to learn more than one, and certainly more than two languages at once.

Yes, you can learn to do HelloWorld in each, but as things start getting deeper something called Cross-Talk by psychologists kicks in and it becomes very hard to remember which language what is coming to your fingertips as you are typing is actually from.

Just as one example, substring() here in Java takes the first index you DO want and the first index you DON'T want.

In C#, it works like this:
public string Substring (int startIndex, int length);

There are countless other things much harder to remember and much more subtle than this, that can cause you to write code that compiles (well, if the language is compiled that is) but doesn't do what you think at runtime.

Guess who has two thumbs, 33 cows and has looked like an idiot getting very basic things like this wrong on interviews because I had to switch back to a language I had used a fair amount from a different one I had been using a lot recently.  This guy.    

That doesn't mean you should be monolingual.  Once you know a language like it is your first language, it is relatively safe to learn others.

But I find I want one coat of paint to dry before trying to paint over it.

Cheers!

EDIT -- in C++, going past the end of your string in a substr() call is just peachy, it gives you all its got, but in Java:
Throws:
IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.

When I was actually a kid, long ago, I did learn many languages at once.  That could have been because I was younger and sharper, however, I think it is more because even the simplest languages are like 50 times as big now as the most complex ones I ever looked at, which was probably PL/I...don't let me discourage you if you can actually learn them all at once, but do be aware if attempting to do so is possibly holding you back...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic