Venkata Sai has Published 62 Articles

How to convert a double value to String in Java?

Venkata Sai

Venkata Sai

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

2K+ Views

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

Can we serialize static variables in Java?

Venkata Sai

Venkata Sai

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

3K+ Views

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

2K+ Views

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

950 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 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

961 Views

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

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

Venkata Sai

Venkata Sai

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

775 Views

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

3K+ Views

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

Does Java support multiple inheritance? Why? How can we resolve this?

Venkata Sai

Venkata Sai

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

5K+ Views

Whenever, you extend a class a copy of superclass’s members is available to the subclass object and, when you can call the method of the superclass using the object of the subclass.ExampleIn the following example, we have a class named SuperClass with a method with name demo(). We are extending ... Read More

Can we cast an object reference to an interface reference in java? If so when?

Venkata Sai

Venkata Sai

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

6K+ Views

Yes, you can.If you implement an interface and provide body to its methods from a class. You can hold object of the that class using the reference variable of the interface i.e. cast an object reference to an interface reference.But, using this you can access the methods of the interface ... Read More

Explain restrictions on using enum in java?

Venkata Sai

Venkata Sai

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

568 Views

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.You can define an enumeration using the keyword enum followed by the name of the enumeration as −enum ... Read More

1 2 3 4 5 ... 7 Next
Advertisements