A constructor provides a convenient way to initialize a newly created object at the time of its creation. It is defined for a class and it is called automatically immediately after the creation of a new object, but before the new operator completes. All Although constructors look the same as methods, they are written by using the following conventions:

  1. A constructor is always given the name of the class in which it is defined.
  2. A constructor is always written without an explicit return type, not even void. This is because the implicit return type of a class constructor is the class itself.

  • Share/Bookmark

What is a narrowing conversion?

A narrowing conversion is an explicit type conversion or casting. It is used when the destination data type is narrower than the source data type, an explicit type conversion is required. The general form of this explicit conversion is given below:

(target-type) value

Here, target-type is the desired data type and value is the value to be converted.

For example:

int num1, int num2;
short num3;
num3= (short)(num1+num2);

  • Share/Bookmark

Prepkit sale on Cyber Monday

Now days uCertify is announcing discounts on multiple prep-kit purchase. uCertify’s discount on certifcation kits on this Cyber Monday discount. Our kits provide’s a strong information over your competition with our top rated exam preparation kits. Buy any three PrepKits for $134.99. uCertify is providing each prepkit withonly $44.99. To add some additonal flavour buy additional PrepKits for only $29.99. Each PrepKit comes with industry Best Money back Gurantee. If you are unable to pass, we will return your money. We provide home and Work license allows you to install PrepKit on two computers.

  • Share/Bookmark

getTime(): The getTime() method returns a date/time of the calendar in a Date object. Date objects are stored as an offset in milliseconds. The general form of the getTime() method is as follows:

Date getTime()

e.g. System.out.println(calendar.getTime());

setTime(): The setTime() method sets the current calendar’s date/time from the value of the specified date. The general form of the setTime() method is as follows:

void setTime(Date date)

e.g. calendar.setTime(date2);

  • Share/Bookmark