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

Why are these errors either runtime or compile-time based?

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
https://imgur.com/a/FEIdr

-var1.two()

-var2.two()

-var3.two()

-var4.one()

-((Yellow) var1).two();

-((Yellow) var4).two();

I guess if i could rephrase, once again.....i know these methods yield errors...but my question is what type of errors are they (either runtime or compile based)? And why are they either runtime or compiler errors? What makes them yield errors at that time?
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please post the full code; many people are reluctant to go to other sites to seek code.
Also please explain which you think will compile and which will produce exceptions, and why.
 
John Sanderval
Greenhorn
Posts: 26
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I cannot post the full code, it takes awhile to type out.

Plus its just an image hosting website. Just click it.

And if anything I believe.....the type of errors will all be runtime errors because the type of method calls i listed out were all over-ride related.....since they are all about that...they are runtime errors.

I am not sure though, which is why I came here asking what they are so i could learn

 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
That appears to be assessed work; you will have to produce answers for yourself and we can look at your answers and explanations.
 
John Sanderval
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Its not like that, I was asked to do homework for this paper, I did all of what they asked on the sheet. I turned it in, but my teacher asked what type of error it was, i exclaimed i didn't really know.  I told her i would try and find out after she checked me off for the assignment, she docked off a few points and then marked me as complete for the assignment.

So now here i am trying to learn what type of error it is and why.

I am not trying to cheat at all. I am just simply using a past homework assignment to better understand why something occurs.
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Well, what happened when you tried to compile that code?
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
What happens if you try var1.two()?
 
John Sanderval
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I haven't really tried, it takes awhile to type something that is natively in an image based format....i was hoping someone here would look at the sheet and kind of give me an idea of what type of error it is.

 
John Sanderval
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
and thus not spend 12 hours on a problem that should take 5 min to answer
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
You could have spent those 5 minutes looking at the code and worked it out, as well as learning something which you won't learn if I tell you the answers.
Look at them; what methods has each declared type got? What is there that might cause an exception to be thrown?
 
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

John Sanderval wrote:it takes awhile to type something


That's a weirdest argument I've heard. Why you chose programming then... There will be always something to type in. Singing wouldn't though. That attitude "wasting time, should take 5 mins..." not acceptable. It will take 5 mins once you get enough knowledge. In order to get such knowledge need to spend much more than 12 hours of learning. If you come to forum to get answer and that is what you call efficient learning - I tend to disagree with you. And in fact, this forum doesn't work that way. We try to teach people how to approach problems themselves, rather than give dry answers.
 
John Sanderval
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I believe the fastest way to teach someone is just to teach them what you know, sometimes helping the person approach the problem themselves can get tedious.

Its much more easier to just give them the answer and help them learn assuming its not for homework
 
John Sanderval
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
everyone learns differently
 
Liutauras Vilda
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I believe CodeRanch collected some good and trusted evidence over the 15 years of research and experience by answering various questions over and over again, which helped to re-assemble some patterns.

I am pretty confident about what I am saying, so don’t think we need to discuss this matter further. From time to time some newcomers disagree, but that is ok, we stick to the way we think is better - many people think that is the reason why these forums here at Ranch are unique and active for so long.

You really could have typed them into your programming environment and got some answers already. Have you tried after all? What you could conclude?
 
John Sanderval
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Honestly I cannot agree that there is a one size fits all kind of type of doing things. I believe the corperation should mold itself constantly around other people's needs.

If you don't agree that is fine but it doesn't mean its the truth for me.

And no that would honestly take a bit of time when a professional could see whats wrong with the program and immediatly give faster results instead of stalling.

As i said I would guess this is a runtime error since we are dealing with over-riding and polymorphism. My class taught me that over-riding is dealt with at runtime. So it seems logical that an error based off that conclusion would also be a runtime error.
 
John Sanderval
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
If i was a teacher i would mold my ways around the students ways. You shouldn't assume a student is lazy just because he learns differently

 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

John Sanderval wrote:. . . I would guess this is a runtime error . . .

Do you mean the first of the lines you mentioned, var1.two()?
Don't guess. If you spent half the time reading the code you were given that you have spent complaining, you could have seen how many two() methods there are in the declared type of var1. You could also have worked out whether there is anything in the two() method that could cause an exception to be thrown. You don't even have a cast in that line to make things more difficult. Calling the classes after colours and calling the methods one(), two(),  and three() doesn't make it any easier, unfortunately.
 
John Sanderval
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Complaining? Dude you don't know my life and what I have to go through constantly and how i constantly see reality

I don't have the best time in life. Especially when all i get from programmers online are rude and snide commentary about this and that.

Save it, if you don't wanna help then dont I am sick of being torn apart by people.

TLDR help me or don't.....I don't care...if you are going to stay though be patient and don't be a duche
 
John Sanderval
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I don't care if I am not the best person in the world and if i do things unconventionally.....I am not perfect. I get that.

So if you guys are gonna be mean, well, this is the last youll here from me
 
Liutauras Vilda
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I'm locking this thread as it has little to no progress in solving any of programming problems due to side irrelevant talks.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic