Tuesday, December 13, 2011

Memory Management in Java : Garbage Collector

Java Garbage Collector is responsible to sweep all the garbage objects remains in memory and leave only those objects which are still referenced on the memory stack. For this, JVM uses 'Mark-Sweep-Compact' three phase techniques. Here JVM give three passes to memory objects to destroy the garbage objects. The process is 

  • In first pass, GC traverses on the Memory Stack and mark all the objects which are referenced from Memory Stack through any scope data structure. 
  • In second pass, GC claims the space of all unmarked objects to release their memory. Before claiming the objects for collection, the demon thread, Garbage Collector, call 'finalize' method of the object in order to give it a chance to do the resource cleanup. Here if any object resurrect it again, i.e. do some activity which put its memory reference back to Memory Stack, garbage collector won't collect its memory and leave this. However in this process, GC maintains a state for the objects for which 'finalize' method has already been called once. In next garbage collection cycle, it does not call the 'finalize' method on this object. 
  • In third pass, garbage collector compact the memory space which was released by second pass and hence made the released memory available for JVM. 

This way, GC manages the memory. The process followed to manage the memory is not light in its processing, as three phases process takes a lot of time to execute and hence is a heavy process. Due to this, JVM does not call the GC very often, but it calls it only when it really feels that memory is low and program may need more memory soon. So even if you are calling System.gc(), it does not mean that JVM will call the GC. However it is just like a request to JVM to consider calling the GC. But JVM has its internal logic to decide when to call the GC. 

 

'Finalize' method is used for resource cleaning process by most of the applications. You can use this method to release any resource like ObjectOutputStream, any handle to an OS file etc. But be very careful while relying on this method. Reason is that JVM does not guarantee to call the finalize method. Consider a condition, when program never face a memory pressure and hence JVM never finds the need to call the GC.  



--
Amit Ranjan
Java developer
............................

Thursday, December 8, 2011

How much memory the java objects consume?

For an empty class:

public class TestClass {

}

size of the TestClass Object is 2 * Reference = 2*4 = 8 bytes.

For a class with primitive – int:

public class TestClass {
int i=0;
}

size = 2 * reference + size of int = 2*4 + 4 = 12 = 16 bytes (word aligned)

For a class with primitive – long:
public class TestClass {
long i=0;
}

size = 2 * reference + size of long= 2*4 + 8 = 16 bytes.

similarly for float and double , the size is 16 bytes.

Taking the wrapper classes,

public class TestClass {
Integer i= new Integer(0);
}
size = 2 * reference for TestClass Object + 2*Reference for Integer
object + size of int

= 2*4 + 2*4 + 4 = 32 bytes (word aligned)

Similarly the sizes for the objects with the Long, Float and Double
fields are32 bytes.

Instead of using the 'new' key word for the Integer instantiation, if
we use Integer i=1; then the results are different.

public class TestClass {
Integer i=0;
}

size = 5152 bytes.

The reason being Integer i=0; is inferred as Integer i= Integer.value(0);

A cache is initialized with all the possible int values varying from
-128 to 127. The 'i' is initialized with the value zero from the
cache.

If you take the String instantiation,

public class TestClass {
String s=new String("i");
}

it consumes about 40 bytes of memory where as,

public class TestClass {
String s="i";
}

consumes about 16 bytes of memory. It took less bytes since "i" is
from the string pool.

Wednesday, November 30, 2011

Multiprogramming, Multicomputing, Multiprocessing and Multitasking

Multiprogramming: program may be any set of commands submitted for execution by a user or operator. In multiprogramming, concurrent running (sharing of the processor) is achieved when the operating system identifies the interruption of one program and gets chance to transfer process control to another program.

Multicomputing: A computer made up of several computers. The term generally refers to an architecture in which each processor has its own memory rather than multiple processors with a shared memory. Something similar to parallel computing.
Distributed computing deals with hardware and software systems containing more than one processing element or storage element, concurrent processes, or multiple programs, running under a loosely or tightly controlled regime.

Multitasking: The ability to execute more than one task at the same time, a task being a program. The terms multitasking and multiprocessing are often used interchangeably, although multiprocessing implies that more than one CPU is involved.

In multitasking, only one CPU is involved, but it switches from one program to another so quickly that it gives the appearance of executing all of the programs at the same time.

There are two basic types of multitasking: preemptive and cooperative. In preemptive multitasking, the operating system parcels out CPU time slices to each program. In cooperative multitasking, each program can control the CPU for as long as it needs it. If a program is not using the CPU, however, it can allow another program to use it temporarily

--
Amit Ranjan
Java developer
.............................
P please consider the environment before printing e-mail-- SAVE PAPER!

Biodata, Resume, CV

Difference among CV Resume and Bio Data

 

People use the words RESUME, C.V., and BIO-DATA interchangeably for the document highlighting skills, education, and experience that a candidate submits when applying for a job. On the surface level, all the three mean the same. However, there are intricate differences.

 

RESUME

Resume is a French word meaning "summary", and true to the word meaning, signifies a summary of one's employment, education, and other skills, used in applying for a new position. A resume seldom exceeds one side of an A4 sheet, and at the most two sides. They do not list out all the education and qualifications, but only highlight specific skills customized to target the job profile in question.

A resume is usually broken into bullets and written in the third person to appear objective and formal. A good resume starts with a brief Summary of Qualifications, followed by Areas of Strength or Industry Expertise in keywords, followed by Professional Experience in reverse chronological order. Focus is on the most recent experiences, and prior experiences summarized. The content aims at providing the reader a balance of responsibilities and accomplishments for each position. After Work experience come Professional Affiliations, Computer Skills, and Education.

 

C.V CURRICULUM VITAE

C.V is a Latin word meaning "course of life". Curriculum Vitae (C.V.) is therefore a regular or particular course of study pertaining to education and life. A CV is more detailed than a resume, usually 2 to 3 pages, but can run even longer as per the requirement. A CV generally lists out every skills, jobs, degrees, and professional affiliations the applicant has acquired, usually in chronological order. A CV displays general talent rather than specific skills for any specific positions.

 

BIO DATA

Bio Data the short form for Biographical Data, is the old-fashioned terminology for Resume or C.V. The emphasis in a bio data is on personal particulars like date of birth, religion, sex, race, nationality, residence, martial status, and the like. Next comes a chronological listing of education and experience. The things normally found in a resume, that is specific skills for the job in question comes last, and are seldom included. Bio-data also includes applications made in specified formats as required by the company.

A resume is ideally suited when applying for middle and senior level positions, where experience and specific skills rather than education is important. A C.V., on the other hand is the preferred option for fresh graduates, people looking for a career change, and those applying for academic positions. The term bio-data is mostly used in India while applying to government jobs, or when applying for research grants and other situations where one has to submit descriptive essays.

Resumes present a summary of highlights and allow the prospective employer to scan through the document visually or electronically, to see if your skills match their available positions. A good resume can do that very effectively, while a C.V. cannot. A bio-data could still perform this role, especially if the format happens to be the one recommended by the employer. Personal information such as age, sex, religion and others, and hobbies are never mentioned in a resume. Many people include such particulars in the C.V. However, this is neither required nor considered in the US market. A Bio-data, on the other hand always include such personal particulars.



--
Amit Ranjan
Java developer
.............................
P please consider the environment before printing e-mail-- SAVE PAPER!

Saturday, November 12, 2011

Be carefull of such emails.

These are not real. They get your personal information.
I am adding one of the email i got to my mail.

Dear Email User.


YOU HAVE WON PRIZE MONEY OF (£500,000.00 GBP) BY GOOGLE /YAHOO LOTTERY FOR
THE YEAR 2011 ANNUAL LOTTERY PROMOTION WHICH IS ORGANIZED BY GOOGLE /YAHOO
IN CO-OPERATIONS. BILLIONS OF EMAIL ADDRESSES HAVE BEEN SELECTED FROM WORLD
WIDE WEB DIRECTORIES. AND DRAWED BY OUR EMAIL BALLOTING MACHINE AND 13 LUCKY
EMAILS HAS EMERGED AS OUR WINNERS FOR THIS YEAR'S SWEEPSTAKE PROGRAMME.

However you will have to fill and submit the below information to the
events manager

1. Full name..............2. Contact Address........

3. Age....................4. Telephone Number.......

5. Sex....................6. Occupation.............

take note ,you have to send your detail to this email id only
cox.3@live.com

(Contact Events manager Lottery Department)

Name: Mr cox rooney

Email:INDX2@MSN.COM

Thursday, October 27, 2011

What ‘new operator’ in java does?

Ans: i. The new operator instantiates a class by allocating memory for a new object ii. The new operator also invokes the constructor. iii. The new operator requires a single, postfix argument: a call to a constructor. iv. The name of the constructor provides the name of the class to instantiate. v. The new operator returns a reference to the object it created. vi. This reference is usually assigned to a variable of the appropriate type.  

If you could click on some of the google ads you see on the right side. It will help me to run this blog and motivates me ;)

Difference between Constructor and Method in java

Constructor:
Method
1.       Constructor is a special method of a class but can’t be invoked directly by method call.
Java doc. Says (A class contains constructors that are invoked to create objects from the class blueprint.)
Methods are member of a class.
2.       It is not a member of a class as it can neither be inherited nor invoked using dot (.) operator.
Dot (.) operator is used to invoke Non static methods via object and static methods via class name.
3.       It has no explicit return type.
It has explicit return type, if there is nothing to return, the return type must be void
4.       It has the same name as its class name.
Can have same name as its class name, but the existence of return type makes it a method (unfortunately looks like constructor).
5.       It is used to initialize the objects, members of object and then execute statements if any.
Used to execute statements.
6.       A no-argument, Default constructor is provided by compiler when no explicit constructor is there. In such case instance members are initialized with their default values (numeric data types are set to 0, char to ‘\0’ and reference variable to null).
Local variable must be initialized explicitly.
7.       If there is no this() as the first statement, super() will be there as first statement in the constructor.
‘this’ is implicitly invoked on all the member in non-static methods, but need explicit invocation in case of name confliction.
Syntax: this.x, this.go()
8.       The default constructor will call the default constructor of its super class due to presence of super() as its first statement.
‘super’ can be used to explicitly invoke member of super class (specially used either in case of name conflict or to call method of super class when overridden in sub-class )
syntax:
 super.member: when name conflict
super.method(args if any) : when overriden

9.       A constructor can never be abstract or static.
A method is of two types defined (implemented) or undefined (abstract). The method implementation can be further categorized as static or non-static. An abstract method can’t be static or final.
10.   Can be specified as public, none (default), protected or private.
Access-specifier public, none (default), protected or private are applicable.
11.   Can’t be final, native, or synchronized. (Constructor can take only access specifier)
Can be final, native, static or synchronized.
12.   Can be invoked by either
a.       new ClassName()
b.      this(args if any)
c.       super(args if any)
d.      getInstance()
Can be invoked by Class name in case of static method or by object/this in case of non-static method.
 
If you could click on some of the google ads you see on the right side. It will help me to run this blog and motivates me ;)

Tuesday, June 28, 2011

How to config a JSP file in web.xml?

Declare following in web.xml file.
<servlet>
<servlet-name>jspName</servlet-name>
<jsp-file>/jspPage.jsp</jsp-file>
     <init-param>
          <param-name>hello</param-name>
           <param-value>test</param-value>
     </init-param>
</servlet>
 
<servlet-mapping>
     <servlet-name>jspName</servlet-name>
     <url-pattern>/jspPage</url-pattern>
 </servlet-mapping>
You can get the value against the parameter hello using following in your jsp page.
<%= config.getInitParameter("hello");%>

--
If you could click on some of the google ads you see on the right side. It will help me to run this blog and motivates me ;)

Friday, April 29, 2011

cost of exception handling

Cost of handling exception


--
Amit Ranjan
Java developer
.............................
P please consider the environment before printing e-mail-- SAVE PAPER!

Saturday, April 9, 2011

MCA Results

1st Sem. (2008-11)
3ed sem. (2009-12)
5th sem. (2010-13)
MCA-10001
MCA-9001
MCA-8001
MCA-10011
MCA-9012
MCA-8012
MCA-10021
MCA-9024
MCA-8023
MCA-10030
MCA-9034
MCA-8033
MCA-10003
MCA-9002
MCA-7037
MCA-10012
MCA-9013
MCA-8002
MCA-10022
MCA-9025
MCA-8013
MCA-10031
MCA-9035
MCA-8024
MCA-10004
MCA-9003
MCA-8034
MCA-10013
MCA-9014
MCA-7039
MCA-10023
MCA-9026
MCA-8003
MCA-10032
MCA-9036
MCA-8014
MCA-10005
MCA-9004
MCA-8025
MCA-10014
MCA-9015
MCA-8035
MCA-10024
MCA-9027
MCA-8004
MCA-10033
MCA-9037
MCA-8015
MCA-10006
MCA-9005
MCA-8026
MCA-10015
MCA-9017
MCA-8036
MCA-10025
MCA-9028
MCA-8005
MCA-10034
MCA-9038
MCA-8016
MCA-10007
MCA-9007
MCA-8027
MCA-10016
MCA-9019
MCA-8037
MCA-10026
MCA-9029
MCA-8007
MCA-10035
MCA-9039
MCA-8017
MCA-10008
MCA-9008
MCA-8028
MCA-10017
MCA-9020
MCA-8038
MCA-10027
MCA-9030
MCA-8008
MCA-10036
MCA-9040
MCA-8018
MCA-10009
MCA-9009
MCA-8029
MCA-10018
MCA-9021
MCA-8039
MCA-10028
MCA-9031
MCA-8009
MCA-10037
MCA-8008
MCA-8019
MCA-10010
MCA-9010
MCA-8030
MCA-10020
MCA-9022
MCA-7005
MCA-10029
MCA-9032
MCA-8010
MCA-9005
MCA-8022
MCA-8020

MCA-9011
MCA-8031

MCA-9023
MCA-7010

MCA-9033
MCA-8011


MCA-8021


MCA-8032


MCA-7023
Promoted:
10002
10019


Regards: Dainik Jagran date 10/4/2011

Friday, April 8, 2011

IPL 2011 Schedule

8-Apr-1120:001stChennai Super Kings vs Kolkata Knight Riders, 1st IPLChennai
9-Apr-1116:002ndDeccan Chargers vs Rajasthan Royals, 2nd IPLHyderabad
9-Apr-1120:003rdKochi Tuskers Kerala vs Royal Challengers Bangalore, 3rd IPLKochi
10-Apr-1116:004thDelhi Daredevils vs Mumbai Indians, 4th IPLDelhi
10-Apr-1120:005thPune Warriors vs Kings XI Punjab, 5th IPLNavi Mumbai
11-Apr-1120:006thKolkata Knight Riders vs Deccan Chargers, 6th IPLKolkata
12-Apr-1116:007thRajasthan Royals vs Delhi Daredevils, 7th IPLJaipur
12-Apr-1120:008thRoyal Challengers Bangalore vs Mumbai Indians, 8th IPLBangalore
13-Apr-1116:009thKings XI Punjab vs Chennai Super Kings, 9th IPLMohali
13-Apr-1120:0010thPune Warriors vs Kochi Tuskers Kerala, 10th IPLNavi Mumbai
14-Apr-1120:0011thDeccan Chargers vs Royal Challengers Bangalore, 11th IPLHyderabad
15-Apr-1116:0012thRajasthan Royals vs Kolkata Knight Riders, 12th IPLJaipur
15-Apr-1120:0013thMumbai Indians vs Kochi Tuskers Kerala, 13th IPLHyderabad
16-Apr-1116:0014thChennai Super Kings vs Royal Challengers Bangalore, 14th IPLChennai
16-Apr-1120:0015thDeccan Chargers vs Kings XI Punjab, 15th IPLHyderabad
17-Apr-1116:0016thPune Warriors vs Delhi Daredevils, 16th IPLNavi Mumbai
17-Apr-1120:0017thKolkata Knight Riders vs Rajasthan Royals, 17th IPLKolkata
18-Apr-1120:0018thKochi Tuskers Kerala vs Chennai Super Kings, 18th IPLKochi
19-Apr-1116:0019thDelhi Daredevils vs Deccan Chargers, 19th IPLDelhi
19-Apr-1120:0020thRoyal Challengers Bangalore vs Rajasthan Royals, 20th IPLBangalore
20-Apr-1116:0021stMumbai Indians vs Pune Warriors, 21st IPLMumbai
20-Apr-1120:0022ndKolkata Knight Riders vs Kochi Tuskers Kerala, 22nd IPLKolkata
21-Apr-1120:0023rdKings XI Punjab vs Rajasthan Royals, 23rd IPLMohali
22-Apr-1116:0024thKolkata Knight Riders vs Royal Challengers Bangalore, 24th IPLKolkata
22-Apr-1120:0025thMumbai Indians vs Chennai Super Kings, 25th IPLMumbai
23-Apr-1120:0026thDelhi Daredevils vs Kings XI Punjab, 26th IPLDelhi
24-Apr-1116:0027thDeccan Chargers vs Mumbai Indians, 27th IPLHyderabad
24-Apr-1120:0028thRajasthan Royals vs Kochi Tuskers Kerala, 28th IPLJaipur
25-Apr-1120:0029thChennai Super Kings vs Pune Warriors, 29th IPLChennai
26-Apr-1120:0030thDelhi Daredevils vs Royal Challengers Bangalore, 30th IPLDelhi
27-Apr-1116:0031stPune Warriors vs Chennai Super Kings, 31st IPLNavi Mumbai
27-Apr-1120:0032ndKochi Tuskers Kerala vs Deccan Chargers, 32nd IPLKochi
28-Apr-1120:0033rdDelhi Daredevils vs Kolkata Knight Riders, 33rd IPLDelhi
29-Apr-1116:0034thRajasthan Royals vs Mumbai Indians, 34th IPLJaipur
29-Apr-1120:0035thRoyal Challengers Bangalore vs Pune Warriors, 35th IPLBangalore
30-Apr-1116:0036thKochi Tuskers Kerala vs Delhi Daredevils, 36th IPLKochi
30-Apr-1120:0037thKolkata Knight Riders vs Kings XI Punjab, 37th IPLKolkata
1-May-1116:0038thRajasthan Royals vs Pune Warriors, 38th IPLJaipur
1-May-1120:0039thChennai Super Kings vs Deccan Chargers, 39th IPLChennai
2-May-1116:0040thMumbai Indians vs Kings XI Punjab, 40th IPLMumbai
2-May-1120:0041stDelhi Daredevils vs Kochi Tuskers Kerala, 41st IPLDelhi
3-May-1120:0042ndDeccan Chargers vs Kolkata Knight Riders, 42nd IPLHyderabad
4-May-1116:0043rdChennai Super Kings vs Rajasthan Royals, 43rd IPLChennai
4-May-1120:0044thPune Warriors vs Mumbai Indians, 44th IPLNavi Mumbai
5-May-1116:0045thKochi Tuskers Kerala vs Kolkata Knight Riders, 45th IPLKochi
5-May-1120:0046thDeccan Chargers vs Delhi Daredevils, 46th IPLHyderabad
6-May-1120:0047thRoyal Challengers Bangalore vs Kings XI Punjab, 47th IPLBangalore
7-May-1116:0048thKolkata Knight Riders vs Chennai Super Kings, 48th IPLKolkata
7-May-1120:0049thMumbai Indians vs Delhi Daredevils, 49th IPLMumbai
8-May-1116:0050thRoyal Challengers Bangalore vs Kochi Tuskers Kerala, 50th IPLBangalore
8-May-1120:0051stKings XI Punjab vs Pune Warriors, 51st IPLMohali
9-May-1120:0052ndRajasthan Royals vs Chennai Super Kings, 52nd IPLJaipur
10-May-1116:0053rdDeccan Chargers vs Pune Warriors, 53rd IPLHyderabad
10-May-1120:0054thKings XI Punjab vs Mumbai Indians, 54th IPLMohali
11-May-1120:0055thRajasthan Royals vs Royal Challengers Bangalore, 55th IPLJaipur
12-May-1120:0056thChennai Super Kings vs Delhi Daredevils, 56th IPLChennai
13-May-1120:0057thKochi Tuskers Kerala vs Kings XI Punjab, 57th IPLIndore
14-May-1116:0058thRoyal Challengers Bangalore vs Kolkata Knight Riders, 58th IPLBangalore
14-May-1120:0059thMumbai Indians vs Deccan Chargers, 59th IPLMumbai
15-May-1120:0060thKings XI Punjab vs Delhi Daredevils, 60th IPLDharmasala
15-May-1120:0061stKochi Tuskers Kerala vs Rajasthan Royals, 61st IPLIndore
16-May-1120:0062ndPune Warriors vs Deccan Chargers, 62nd IPLNavi Mumbai
17-May-1120:0063rdKings XI Punjab vs Royal Challengers Bangalore, 63rd IPLDharmasala
18-May-1120:0064thChennai Super Kings vs Kochi Tuskers Kerala, 64th IPLChennai
19-May-1120:0065thPune Warriors vs Kolkata Knight Riders, 65th IPLNavi Mumbai
20-May-1120:0066thMumbai Indians vs Rajasthan Royals, 66th IPLMumbai
21-May-1116:0067thKings XI Punjab vs Deccan Chargers, 67th IPLDharmasala
21-May-1120:0068thDelhi Daredevils vs Pune Warriors, 68th IPLDelhi
22-May-1116:0069thRoyal Challengers Bangalore vs Chennai Super Kings, 69th IPLBangalore
22-May-1120:0070thKolkata Knight Riders vs Mumbai Indians, 70th IPLKolkata
24-May-1120:0071stTBC vs TBC, Qualifier 1 IPLMumbai
25-May-1120:0072ndTBC vs TBC, Eliminator IPLMumbai
27-May-1120:0073rdTBC vs TBC, Qualifier 2 IPLChennai
28-May-1120:00FinalTBC vs TBC, Final IPLChennai