File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes please answer my query? 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 "please answer my query?" Watch "please answer my query?" New topic

please answer my query?

payal sharma
Ranch Hand

Joined: Oct 04, 2000
Posts: 57
I am unable to understand this?

here why I am getting compile time error as Identifier expected.
v=new Vector();
Although I am changing the refrence of the final object not the object itself.
I can change its reference in contructor if I put v=new Vector() in constructor.
but here Blank final variable 'v' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
final Vector v;
but If assigned value in initializer then

I am geting error Undefined variable or class name: v
static {
final Vector v;
v=new Vector();
making initializer static giving the same problem why?
Q2 Why top level class can not be static?

here object a1 is of tyep AnInterface but reference of AnInterfaceImpl.
Call method on this object is giving compile time error methodOne do not catch or throw Exception.
But why

this compiles and with out and error or exception.

this giving not equal
Bill Tripper

Joined: May 30, 2001
Posts: 24
Q1: The statement "v = new Vector()" is floating out there where your variable declarations belong. You can put it into an initializer block, e.g., "{v = new Vector();}" and it will work.
Instead of:
final Vector v;
v=new Vector();
final Vector v;
v = new Vector();
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
or why not just code:
final Vector v = new Vector();
Tom - SCJP --- Co-Moderator of the Programmer Certification Forums

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Mini Pilla
Ranch Hand

Joined: Jul 15, 2001
Posts: 112

Ya this will also work or rather should.

Originally posted by Thomas Paul:
or why not just code:
final Vector v = new Vector();

wei luo

Joined: Mar 15, 2001
Posts: 23
I think "final Vector v;
public AllFinals()
{ v = new Vector();
will also work.
I agree. Here's the link:
subject: please answer my query?
It's not a secret anymore!