The moose likes Beginning Java and the fly likes Some Questions ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Some Questions ?" Watch "Some Questions ?" New topic

Some Questions ?

Harjeet Dadwal

Joined: Sep 09, 2001
Posts: 17
1> when an object of class is created then if we haven�t defined any constructor for that class then the default constructor runs, WHERE THIS DEFAULT CONSTRUCTOR LOCATED IS ?
2> why the local variable cannot be declared final ?
3> We cannot print an object of a class directly using println() method , we have to call toString() method but why object of class File is printed directly:-eg. File fi=new File(�C:\dir1\file1.txt�);and it prints as using System.out.println(f1);
4> What is difference between getPath() and getAbsolutePath() in file handeling ?
5> Is there no method to create file directly as we create directory ?

Harjeet Singh Dadwal

Harjeet Dadhwal
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
Ill try to answer some of these:
1) The default no-argument constructor is created b y the compiler. If the programmer has supplied ANY constructors of any type, the compiler does not create the no-argument constructor.
2)I think a variable can be declared final in any scope. As a matter of fact, a final local variable has the special property of being able to declare it, and defer assignment of a value to it until later.
3)You dont need to explicitly call the toString() method when printing an object. The toString() method is implicitly called when you do System.out.println()
4)I dont really know this one. I do know that the absolute path gives you a complete path where no other information would be necessary to find the file. I dont do enough io to know the difference between the two methods.
5)I think createNewFile() will do this for you.
Good luck!
I agree. Here's the link:
subject: Some Questions ?
It's not a secret anymore!