You are on page 1of 3

ASSGNMNT :- JAVA SUBMITTED BY:-MOHD.

ASIF ROLL NO- RK1R11B31

ANS 5:-we can declared a local class inside a static method have access to the instance members of the outer class. The class declared inside a static method can acess to the instance members of the outer class by creating the obj of outer class inside a local class which is inside static method.

example: public class InnerClass {

int i = 9;

static void method1() {

final int k = 6; class MethodLocal { Innerclass obj=new Innerclass(); MethodLocal() { System.out.println(k + obj.i); } } }

} ANS:3-abstract class saleman { char name[20]; int price; void getname(char s[]) { name=s; } void getprice(int x) { price=x; }

abstract void reduceprice();

} class Productprinter extends Product { void reduceprice() { int c; c=price-500; } void result() {

System.out.println("price is"price); System.out.println("name is"+name);

System.out.println("reduced price is"+c);

class Check { public static void main(String args[]) { saleman obj = new Productprinter(); obj.getname(); obj.get_price(); obj.reduceprice(); obj.result(); } }

You might also like