Sealed Class in Java with Examples

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Program 1

sealed interface MyInter1 permits MyInter2
{

}

non-sealed interface MyInter2 extends MyInter1
{

}
interface MyInter3 extends MyInter1
{

}

class TestSealed
{
  public static void main(String args[])
{

}
}







// sealed class First permits Second,Third
// {

// }
// sealed class Second extends First permits Four
// {

// }
// non-sealed class Four extends Second
// {}


 

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *