Question: Using Java Theory: Modifier public private default protected Description The code is accessible for all classes The code is only accessible within the declared class


Using Java
Theory: Modifier public private default protected Description The code is accessible for all classes The code is only accessible within the declared class The code is only accessible in the same package. This is used when you don't specify a modifier. The code is accessible in the same package and subclasses. Modifier Public Protected Default Class Yes Yes Package Subclass Global Yes Yes Yes Yes Yes No Yes Yes No No Private Yes No No No PROGRAM#1: Given below code, read it carefully then answer next questions: Public class Employee { Public int ID =12390; Public String Name="Hiba"; Private double Salary = 2000.00; Protected String address ="Tabuk; String phone ="+966-596-277-088"; Public void Hello) {System.out.print("Hello");} } a. Write the implementation for above code, and create Demo class. b. Inside demo class create new instance to print the value for Employee class attribute. c. Change the access modifier for "Hello" method and try to call the method. d. Define the default constructor for Employee class, then find the output. e. Define another parametrized constructor for Employee class, then find the output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
