Venkata Sai has Published 72 Answers

How to convert a double value to String in Java?

Venkata Sai

Venkata Sai

Updated on 04-May-2022 13:10:21

The double data type in Java stores double-precision 64-bit IEEE 754 floating point number. It is used as the default type for decimal value in Java.Like all other primitive variables double also have a wrapper class (Double) wrapping the primitive data type. Since java supports auto boxing, the primitive value ... Read More

How do we compare the members of enums in Java?

Venkata Sai

Venkata Sai

Updated on 30-Jun-2020 07:46:19

Enumeration (enum) in Java is a datatype which stores a set of constant values. You can use enumerations to store fixed values such as days in a week, months in a year etc.enum Days {    SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }You can also define an enumeration with ... Read More

Explain wrapper classes in Java?

Venkata Sai

Venkata Sai

Updated on 29-Jun-2020 14:50:12

Java provides certain classes called wrapper classes in the java.lang package. The objects of these classes wraps primitive datatypes within them. Following is the list of primitive datatypes and their respective classes −Primitive datatypeWrapper classcharCharacterbyteByteshortShortintIntegerlongLongfloatFloatdoubleDoublebooleanBooleanFollowing Java example accepts various primitive variables from the user and creates their respective wrapper classes.Exampleimport ... Read More

Can we serialize static variables in Java?

Venkata Sai

Venkata Sai

Updated on 29-Jun-2020 14:48:49

In Java, serialization is a concept using which we can write the state of an object into a byte stream so that we can transfer it over the network (using technologies like JPA and RMI).But, static variables belong to class therefore, you cannot serialize static variables in Java. Still if ... Read More

Explain how to remove Leading Zeroes from a String in Java

Venkata Sai

Venkata Sai

Updated on 29-Jun-2020 14:48:21

Whenever you read an integer value into a String, you can remove leading zeroes of it using StringBuffer class, using regular expressions or, by converting the given String to character array.Converting to character arrayFollowing Java program reads an integer value from the user into a String and removes the leading zeroes ... Read More

Can we cast reference variables in Java?

Venkata Sai

Venkata Sai

Updated on 06-Aug-2019 12:49:02

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 and, reference datatypes (arrays and objects).Casting in JavaConverting one primitive data type into another is known as type casting.Exampleimport java.util.Scanner; public class TypeCastingExample { ... Read More

Explain naming conventions for packages in java?

Venkata Sai

Venkata Sai

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

While choosing a package name you need to keep the following points in mind.The name of the package should be in small letters.It is suggested to start the name of the package with the top level domain level followed by sub domains, ex: com.example.tutorialspoint.ExampleYou can declare a package as −package ... Read More

What are static imports in java? Example.

Venkata Sai

Venkata Sai

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

Whenever you need to access a class which is not in the current package of the program you need to import that particular class using the import statement.ExampleIn the following example, we are using the Math class to find the square root of a number, therefore, first of all, w ... Read More

Can we declare the method of an Interface final in java?

Venkata Sai

Venkata Sai

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

An interface in Java is a specification of method prototypes. Whenever you need to guide the programmer or, make a contract specifying how the methods and fields of a type should be you can define an interface.By default, all the methods of an interface are public and abstract. For example, ... Read More

What are the modifiers allowed for methods in an Interface in java?

Venkata Sai

Venkata Sai

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

An interface in Java is a specification of method prototypes. Whenever you need to guide the programmer or, make a contract specifying how the methods and fields of a type should be you can define an interface.In Java 7As of Java7 you can have only public, abstract as modifiers for ... Read More

1 2 3 4 5 6 7 8 Next
Advertisements