0

Java errors in a program

Class Student { int roll; int getroll(int x) { roll=x; } void putroll() { System.out.println("ROLL NUMBER IS ENTERED BY THE USER IS"+roll); } } Class Test extends Student { int getmarks(int a,int b, int c,int d,int e) { int java,python,nodejs,android,ds; java=a; python=b; nodejs=c; android=d; ds=e; } int putmarks() { System.out.println("Test 1 marks is"+java); System.out.println("Test 2 marks is"+python); System.out.println("Test 3 marks is "+nodejs); System.out.println("Test 4 marks is "+android); System.out.println("Test 5 marks is"+ds); } } Class Result extends Test { int display { putroll(); putmarks(); int total=java+python+nodejs+android+ds; } } Class Main { public Static void main (String arg[]) { Result obj=new Result(); obj.getroll(1); obj.getmarks(100,200,300,400,500); obj.diplay(); } }

26th Jul 2022, 4:13 AM
Abhishek
Abhishek - avatar
3 ответов
+ 1
abhishek bairwa Make code in Code playground and share the link here. It would be easy to help you.
26th Jul 2022, 5:21 AM
A͢J
A͢J - avatar
+ 1
Learn about variable scope. Variable declared within a block or method will have local scope to method so outside of that block, won't exist.. getmarks() variables won't exist in putmarks() variables..
26th Jul 2022, 8:41 AM
Jayakrishna 🇮🇳
- 1
I want to tell u that yaha par multilevel inheritance ho raha hai so it's doesn't matter
27th Jul 2022, 4:04 AM
Abhishek
Abhishek - avatar