Maruthi Krishna has Published 464 Articles

Why does Java strictly specify the range and behavior of its primitive types?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 12:31:17

400 Views

Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double.Java strictly specifies range and behaviors of all the primitive datatypes. Making the users choose the required datatypes based on the application thus reducing the ... Read More

List out the default values of numeric and non-numeric primitive data types in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 12:21:52

577 Views

When you create instance variables in Java you need to initialize them, else the compiler will initialize on your behalf with default values which are −byte: 0short: 0int: 0long: 0float: 0.0double: 0.0boolean: falsestring: nullExampleIn the following Java program prints the default values of the numeric and non-numeric primitive variables in ... Read More

How to call the constructor of a superclass from a constructor in java?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 12:09:16

6K+ Views

Whenever you inherit/extend a class, a copy of superclass’s members is created in the subclass object and thus, using the subclass object you can access the members of both classes.ExampleIn the following example we have a class named SuperClass with a method with name demo(). We are extending this class ... Read More

Is it possible to use this keyword in static context in java?

Maruthi Krishna

Maruthi Krishna

Updated on 30-Jul-2019 22:30:26

1K+ Views

A static method or, block belongs to the class and these will be loaded into the memory along with the class. You can invoke static methods without creating an object. (using the class name as reference).Whereas "this" in Java acts as a reference to the current object. But static contexts(methods and ... Read More

Advertisements