Win a copy of Event Streams in Action this week in the Java in General forum!

Rahul Parakkat

Greenhorn
+ Follow
since Feb 13, 2012
Rahul likes ...
Java Netbeans IDE Ubuntu
pune, india
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rahul Parakkat

Rahul Parakkat wrote:finalize() is a method from java Object class, when there are no active references to an object "finalize" method will be called by Garbage Collector,
finalize method can be called once on any given object ( by JVM )

finally block

this block can be used to write code, that you want to execute in any case ( meaning irrespective of whether the try block throws some exception or not - the statements in finally block will be always executed unless and until there is a preceding System.exit() call in code)

in the coding scenarios that i have seen, this block is used release all the open connections and resources

just a prototype :

finally
{

if(Connection != null)
connection = null

if(Resultset != null )
Resultset = null
}

Regards
Rahul Parakkat



read the prototype as below : sorry for initial wrong way of closing connection & resultset

just a prototype :

finally
{

if(Connection != null)
connection.close()

if(Resultset != null )
Resultset.close()
}
finalize() is a method from java Object class, when there are no active references to an object "finalize" method will be called by Garbage Collector,
finalize method can be called once on any given object ( by JVM )

finally block

this block can be used to write code, that you want to execute in any case ( meaning irrespective of whether the try block throws some exception or not - the statements in finally block will be always executed unless and until there is a preceding System.exit() call in code)

in the coding scenarios that i have seen, this block is used release all the open connections and resources

just a prototype :

finally
{

if(Connection != null)
connection = null

if(Resultset != null )
Resultset = null
}

Regards
Rahul Parakkat
As it is given in your question, it may not even compile

reason : The double variable declaration cannot be 107_f ( the f token has to be without any space from the float/double literal )

If the Question was like this :

package mnp;

class Boo {
double foo = 107f; // Note the double declaration
}
class Derived extends Boo {
double foo = 145f;
}
class Inherit {
public static void main(String args[]) {
Boo base = new Derived();
System.out.println(base.foo);
}
}


The code would compile & run successfully , producing output

107.0

Reason is : Even though class Derived extends Boo, as part of inheritance only methods are inherited and not the instance variables
So the Boo reference variable is still referring to its own instance variable

Note : Please go through Inheritance , Overloading & Overriding for better understanding

Hi

I am planning to give OCA SE 7 Java Programmer Exam 1,

can anyone help me to clarify that the below given book would be good enough for preparation

Name : oracle_certified_associate_java_se_7_programmer_study_guide
Author : Richard M Reese
First published: August 2012
Production Reference: 1160812
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84968-732-4

Did anybody refer this book as part of their preparation for OCAJP exam ??

Regards
Rahul Parakkat
When ever i took any practise scjp test, i got vey low score in garbage collection. After reading this post, i am lot more clear on the idea of GC.

Thanks a lot Bert Bates & Kathy Sierra. I am reading your book on SCJP 1.6

Its little more fun here : http://radio.javaranch.com/corey/2004/03/25/1080237422000.html


Sincerely
Rahul Parakkat
Hi All,

I have recently joined this wonderful java world. I have got one doubt while going through Kathy Sierra and Bert Bates book for scjp ( ocjp ) - 6.

Topic : operators

Sub-Topic : short circuit and non-short-circuit operators.

Doubt :

what would be the result of the code if the following one is executed....?

int z = 5;

if ( ++z < 5 & ++z > 6 )
{
System.out.println(++z);
}

Output i got is : <nothing printed>

question : when we use a non-short-circuit operator ( & , | ), will both the operands get executed always, irrespective of the output of operands...?


Looking forward to your reply...

Warm Regards
Rahul Parakkat
Pune