DEV Community

hema latha
hema latha

Posted on

My Assignments

Create a class Called School.
Have non-static variables as below.
int mark;
private int salary;
Have static variable as below.
static String school_name = "St. Antony's Primary School";
Define non-static methods mentioned below
void conduct_exams()

  • Have a print statement inside this method void publish_results(int mark)
  • Have a print statement inside this method to print mark Now, create another class called Teacher Create main method inside Teacher class Create an instance(object) for School class [Object name -> teacher] Using 'teacher' object, call conduct_exams() method Using 'teacher' object, call publish_results() method and pass 75 as argument here. Print school_name Try to access private variable salary in Teacher class and note down the error message.

package task;

public class School {
int mark;
private int salary;// non static
static String school_name = "St. Antony's Primary School";

//private void sysout() {
// TODO Auto-generated method stub

void conduct_exams()
{
System.out.println("science exam");
}
void publish_result(int mark)
{
System.out.println(mark);

}
void school_name()
{
System.out.println(school_name);
}
}

package task;

public class Teacher {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    School little = new School();
    little.conduct_exams();
    little.publish_result(75);
    little.school_name();
        }
Enter fullscreen mode Exit fullscreen mode

}
out put ----
science exam
75
St. Antony's Primary School

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more