• Post Reply 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Some Questions ?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic