Venkata Sai has Published 62 Articles

Explain restrictions on using enum in java?

Venkata Sai

Venkata Sai

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

617 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

What are enumerations in Java? How to retrieve values from an enum?

Venkata Sai

Venkata Sai

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

529 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

Can we have variables and methods in an enum in Java?

Venkata Sai

Venkata Sai

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

3K+ 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

Can we create an enum with custom values in java?

Venkata Sai

Venkata Sai

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

8K+ Views

Enumeration (enum) in Java is a datatype which stores a set of constant values (Strings in general). 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 }Custom values ... Read More

How to use an enum with switch case in Java?

Venkata Sai

Venkata Sai

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

1K+ 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.enum Days { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }You can also define an enumeration with custom ... Read More

How to iterate the values in an enum in Java?

Venkata Sai

Venkata Sai

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

15K+ 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.enum Days { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }You can iterate the contents ... Read More

How to convert a String to an enum in Java?

Venkata Sai

Venkata Sai

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

3K+ Views

The valueOf() method of the Enum class in java accepts a String value and returns an enum constant of the specified type.ExampleLet us create an enum with name Vehicles with 5 constants representing models of 5 different scoters with their prices as values, as shown below −enum Vehicles { ... Read More

Explain about field hiding in java?

Venkata Sai

Venkata Sai

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

928 Views

Whenever you inherit a superclass a copy of superclass’s members is created at the subclass and you using its object you can access the superclass members.If the superclass and the subclass have instance variable of same name, if you access it using the subclass object, the subclass field hides the ... Read More

What is variable shadowing in java?

Venkata Sai

Venkata Sai

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

4K+ Views

In Java you can declare three types of variables namely, instance variables, static variables and, local variables.Local variables − Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has ... Read More

What are the rules to be followed while using varargs in java?

Venkata Sai

Venkata Sai

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

224 Views

Since JSE1.5 you can pass a variable number of values as argument to a method. These arguments are known as var args and they are represented by three dots (…)Syntaxpublic myMethod(int ... a) { // method body }Rules to follow while using varargs in JavaWe can have ... Read More

Advertisements