IntelliJ Java IDE
The moose likes Jobs Discussion and the fly likes Final Classes in java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Careers » Jobs Discussion
Reply Bookmark "Final Classes in java" Watch "Final Classes in java" New topic
Author

Final Classes in java

tushar bhasme
Ranch Hand

Joined: Feb 11, 2008
Posts: 50
I recently gave an interview in a company...
One of the questions brought up collections- then it went to customization...
For something i said that i would extend ArrayList and implement my own... on this the guy taking my interview said its not possible...

I now think I should have taken him down at that point itself... cause I couldn't get through the interview anyways (he started asking me sql and stuff that i didnt have much idea about )...

But to think about it, are there any classes other than String, Integer, Float etc that are final?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 14606


Hopefully, it was just a wording issue, and not intended to actually humiliate. Or maybe the interviewer was trying to get to a point, and cutting you off was the easiest way to stop a detour (although not the best way).

I'll admit that I have embarrassed interviewees a few times -- one time at exactly the same point where management walked in. In every case, it was *NOT* intentional. An interview is a two way street. The last thing that I want is an interviewee leaving with such a bad taste that he/she no longer want to consider the company.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
tushar bhasme
Ranch Hand

Joined: Feb 11, 2008
Posts: 50
well... he did not want to humiliate me, but i felt so cause i didn't defend myself... and there were 2 guys who were taking my interview... and BOTH of them said you cannot extend Array List...

Anyways... I actually wanted to discuss if there are any Final classes other than String, Float etc....
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 11642

By "you cannot extend ArrayList", did they mean that it is not possible, i.e. you would get a compiler error, or did they really mean that you should not extend ArrayList? Or, maybe, that for the purpose of the interview question they added a restriction that your answer should not include extending ArrayList?

You can interpret it in different ways...

Class java.util.ArrayList is not final, so it is not impossible to extend ArrayList. (I don't think that it's a good idea in general to do it, but it's not impossible).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
tushar bhasme
Ranch Hand

Joined: Feb 11, 2008
Posts: 50
they ACTUALLY said that it cannot be extended... and that it's final class...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 13842

tushar bhasme wrote:they ACTUALLY said that it cannot be extended... and that it's final class...


You can (and should) check the API documentation. That's the definitive way of answering questions like this, trying to find better experts isn't necessary.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 3688

Paul Clapham wrote: That's the definitive way of answering questions like this, trying to find better experts isn't necessary.

What?!?! You want to let things like facts get in the way of opinion?
tushar bhasme
Ranch Hand

Joined: Feb 11, 2008
Posts: 50
guys... i know Array List IS extendable and is NOT final... and that those people were wrong...

all i wanted to know was are there any classes other than the wrappers- like Integer, Float, and of course String that are final?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 14606

tushar bhasme wrote:
all i wanted to know was are there any classes other than the wrappers- like Integer, Float, and of course String that are final?


This topic was originally in MD, which definitely wasn't the right place for this topic. Now, this topic is in JD, which is much better, but I am not sure if the specific portion of this topic, about what classes are final, are best answered here. Oh, well... here's hope for the best.

Henry
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 13842

I'm sure there are some. You could search the API documentation for them if you liked.

And no, I don't mean opening up each of the 5,000 classes in your browser and looking for the word "final". I mean something more applicable to a computer programmer. Like writing a program which searches the documentation's HTML pages for instances of the word "final" and then reviewing the results. Computer programmers are supposed to be lazy, but that just means that they write programs which do boring and tedious stuff instead of doing the boring and tedious stuff themselves.
tushar bhasme
Ranch Hand

Joined: Feb 11, 2008
Posts: 50
Paul Clapham wrote: but that just means that they write programs which do boring and tedious stuff instead of doing the boring and tedious stuff themselves.


i loved this reply... :D
this is 100% true...
and thanks for the suggestion...
 
 
subject: Final Classes in java
 
Threads others viewed
Non-static inner classes
is it professional
A question for all those who returned to India...
Method parameters passed by reference/value
Final HR interview after several interviews (US Jobs)
developer file tools