aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Using of  final keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Using of  final keyword" Watch "Using of  final keyword" New topic
Author

Using of final keyword

Rahul Noel
Ranch Hand

Joined: Jul 18, 2008
Posts: 51


My Question what is the difference between line no. 6 & 7.I mean both are working what is the purpose of the using final in line 6. please let me know.


Thanks in Advance.
Ivan Vrtacnik
Greenhorn

Joined: Sep 02, 2008
Posts: 26
Final is a keyword that is relevant to inheritance, not behaviour of the variable in the given class.

It means that the final variable cannot be inherited by children of this class.
Ganeshkumar cheekati
Ranch Hand

Joined: Oct 13, 2008
Posts: 362
you can modify the status of the object which you created in line 6 eventhough you are using final keyword.

the main use of final is you cannot use that reference variable to point to another object.that means reference can not be changed.


SCJP5 and SCWCD1.5
Think Twice Act Wise...
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775


Ivan Vrtacnik
----
Final is a keyword that is relevant to inheritance, not behaviour of the variable in the given class.


Inheritance has nothing to do with the given code. Reference variable "test" is local to main method. Here it means you cannot assign any object to "test" reference variable. But you can do this later in the code...



but not with test reference because it's final and you cannot re-assign anything to it once you assign an object this case .


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Rahul Noel
Ranch Hand

Joined: Jul 18, 2008
Posts: 51
Hi Friends,
Thanks for your quick response and clarifying my doubt.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using of final keyword
 
Similar Threads
Why did String not change?
K&B CHAPTER:8 q.no:9.........
how to answer "compile error on line ##"?
Updated K&B 5 Errata - 4/16
K&B SCJP 5: Chapter 8, Self Test 9, wrong answer?