---
title: "Can a class be declared as protected?"  
description: "Can a class be declared as protected?"  
author: "Odilian Gosselin"  
published: 2017-12-21  
canonical: https://answers.mindstick.com/qa/31887/can-a-class-be-declared-as-protected  
category: "technology"  
tags: ["java programming"]  
reading_time: 1 minute  

---

# Can a class be declared as protected?

Can a [class](https://www.mindstick.com/articles/12089/arrays-in-java-determining-class-of-an-array-part-8) be [declared as](https://answers.mindstick.com/qa/34765/which-state-is-the-second-state-in-north-east-after-sikkim-to-declared-as-the-open-defecation-free-state) protected?

## Answers

### Answer by Hemant Patel

No, a **class** can't be declared as **protected**. Because *protected access modifier can't be applied to class and interfaces.* You can declare **inner and nested classes as private or protected**. In Java you can declare protected **Methods and fields**, however, methods and fields in an interface cannot be declared protected. Here is one of the big reason for why we can't declare the class using protected access modifier because the access modifier for outer level classes defines their visibility in relation to other assemblies. In Java, only two valid declarations for a class at the namespace level, "**Public**" and "**Internal**.

## *Hope it's informative for you...*


---

Original Source: https://answers.mindstick.com/qa/31887/can-a-class-be-declared-as-protected

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
