No enclosing instance of type MultipleObject is accessible

Viewed 12

i am trying to call multiple function in single object but i am getting error

Description Resource Path Location Type No enclosing instance of type MultipleObject is accessible. Must qualify the allocation with an enclosing instance of type MultipleObject (e.g. x.new A() where x is an instance of MultipleObject). MultipleObject.java /MultipleObject/src line 37 Java Problem


public class MultipleObject {
class student{
    int rollno;
    String name;
    int age;
    int mark1;
    int mark2;
    student(int r,String n,int a,int m1,int m2)
    {
        rollno=r;
        name=n;
        age=a;
        mark1=m1;
        mark2=m2;
    }
    void display()
    {
        System.out.println("Roll no is"+rollno);
        System.out.println("Name is"+name);
        System.out.println("Age is"+ age);
    }
    void total()
    {
        int totalmark=mark1+mark2;
        System.out.println("Total mark"+totalmark);
    }
    }
    

    public MultipleObject() {
        // TODO Auto-generated constructor stub
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        student s=new student(10,"syed",20,30,40);
        s.display();
        s.total();

    }
    
}
'''
help me to solve, i am new to java
thanks in advance

0 Answers
Related