- Create a class ‘Employee’
- Have main method in it.
- Inside main method, create an object.
- Using this object, call method called ‘develop’.
- using this object, call method called ‘work(10)’
- Define appropriate methods develop() and work(int no)
- From work method, return no * 10
- Store the returned value as ‘output’ in main method.
- Print the ‘output’.
Input:
class Employee{public static void main(String[] args){Employee emplo=new Employee(); //object creationemplo.develop(); //method callingint output= emplo.work(10);System.out.println("work" +" "+ output);}public int work(int no){return no * 10;}public void develop(){}}class Employee { public static void main(String[] args) { Employee emplo=new Employee(); //object creation emplo.develop(); //method calling int output= emplo.work(10); System.out.println("work" +" "+ output); } public int work(int no) { return no * 10; } public void develop() { } }class Employee { public static void main(String[] args) { Employee emplo=new Employee(); //object creation emplo.develop(); //method calling int output= emplo.work(10); System.out.println("work" +" "+ output); } public int work(int no) { return no * 10; } public void develop() { } }
Enter fullscreen mode Exit fullscreen mode
Output:
原文链接:Day 10 Task:
© 版权声明
THE END
暂无评论内容