Munish Dabra

+ Follow
since Jan 07, 2001
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Munish Dabra

import java.lang.Math;
class MathAbsSup
public static void main(String args[])

//Why Math.abs() is giving negative output??? (-2147483648)
f=a statement is equalent to
GenericFruit f = new Apple();
that means f is a super class reference to subclass object a.
Now Acoording to superclass refrence rules
--Superclass refrence determines the varible.
--Subclass object determines the method.
Note: here if u call a method which has been overridden by ur subclass
Apple.and u did same i.e
then overridden method of subclass will execute.because method is determined by
underlying subclass object.
i hope u will get it.
Munish Dabra
class MyGC
static int num;
MyGC(int n)
public static void main(String ar[])
MyGC var1=new MyGC(2);
double array[]=new double[999999]; //Suggestion for gc to run
MyGC var2=new MyGC(1);
System.out.println("Yahoo! i am exiting main()");
protected void finalize() throws Throwable
System.out.println("i am known as Mr. finalize "+num);

Yahoo! i am exiting main()
i am known as Mr. finalize 1
i am known as Mr. finalize 1
waht's is executing finalize for avr2 just can'nt possible.
constructing like
RandomaccessFile raf=new RandomAccessFile("xxx","rw");
what will happen if the file xxx is read-only and we try to write.
if the file xxx exist it is opened in append mode true or false
Also if we wrap a string fxx
File f=new File("fxx");
it will compile but when run it will throw exception if fxx
doesnot exist true or false
if true where the file fxx is looked for in current directory or
pls clarify my confusion.or i am missing something.
Ans. File f=new File("fxx");
Yeah if there is n't any such file exists then at run time iit will throw an IOException.
ya amrit ofcourse fxx file is looked in current directory by default.
if u wanna this it to look in some particular directory.then u have to use a different
constructor of File-----
File f=new File(String path,String filename)
File f=new File(File dir , String filename)
here plz note that File object can be a directory or file.ucan check it by
calling boolean method of File class
boolean isFile() or isDirectory().
i hope it will serve the purpose.
Munish Dabra
i found that
-first by calling System.gc() and suggesting GC to garbage collect th object by allocating some free memory.
-immediate after that i declare the object to be null.
-then print statement in the finalize executed 2 times.Why?
No Tom Object serialization and Reflection both r not covered in the Scjp 's exam.
They both did the same job.what actually makes them different at back end