Can Enum implement Class

0 votes
May 26, 2019 in Java by anonymous
251 views

1 answer to this question.

0 votes

Enum is a type similar to that of a class.

The keyword extends is for extending a class.

The keyword implements is for implementing an interface

Can Enum extend a class in java?

Enum cannot extend any class in java,the reason is, by default Enum extends abstract base class java.lang.Enum. Since java does not support multiple inheritance for classes, Enum can not extend another class.

Can Enum implement a interface in java?

Enum can implement any interface in Java. Since enum is a type, similar to any other class and interface, it can implement any interface in java. This gives lot of flexibility to use Enum to implement some other behavior.

answered May 27, 2019 by Sirajul
• 58,990 points

Related Questions In Java

0 votes
1 answer

Can Abstract Class have a Constructor?

Yes, an abstract class can have a ...READ MORE

answered May 11, 2018 in Java by sharth
• 3,350 points
229 views
0 votes
1 answer

Can anyone show how to implement SortByValue in Tree Map for Java ?

You can't have the TreeMap itself sort on the ...READ MORE

answered Dec 10, 2018 in Java by Sushmita
• 6,890 points

edited Dec 10, 2018 by Sushmita 174 views
0 votes
1 answer

JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object?

Hello @kartik, his happens for these reasons: your inner ...READ MORE

answered Apr 8, 2020 in Java by Niroj
• 82,560 points
4,659 views
0 votes
2 answers

How can I create File and write data in it using Java?

import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class WriteFiles{ ...READ MORE

answered Jul 26, 2018 in Java by samarth295
• 2,200 points
481 views
0 votes
1 answer

I am learning looping statements. Can you tell me how 'for-each' works in Java?

While programming we often write code that ...READ MORE

answered Apr 17, 2018 in Java by Rishabh
• 3,620 points
201 views
0 votes
2 answers

“Could not find or load main class” mean?

Use the final modifier to enforce good initialization. Avoid returning ...READ MORE

answered Sep 18, 2018 in Java by Sushmita
• 6,890 points
2,725 views
0 votes
3 answers

How to read input from Console using Scanner Class?

A simple example: import java.util.Scanner; public class Expl { ...READ MORE

answered Jul 31, 2018 in Java by samarth295
• 2,200 points
1,724 views
0 votes
6 answers

How can we define global variables in java?

To define Global Variable you can make ...READ MORE

answered Dec 15, 2020 in Java by Gitika
• 65,870 points
36,115 views
0 votes
2 answers

How can I convert a String variable to a primitive int in Java

 Here are two ways illustrating this: Integer x ...READ MORE

answered Aug 20, 2019 in Java by Sirajul
• 58,990 points
642 views
0 votes
2 answers