• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

plz tell what is wrong in it

 
Amit Sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface A{
void meth1();
int a=5;
}
interface B{
void meth2();
int j=9;
}

class MI implements A,B{
public static void main(String args[]){

public void meth1(){ System.out.println("Method of A and a is:" + a);}
public void meth2(){ System.out.println("Method of B and b is:" + b);}

MI ob=new MI();
ob.meth1();
ob.meth2();
}
}
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're referring to a variable named "b" when there's only "a" and "j"?

You've put the definitions for the two methods that implement the interfaces inside "main"?
[ March 09, 2006: Message edited by: Ernest Friedman-Hill ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, your compiler may not recognize the encoding for the character since it's not part of the Unicode standard - yet! Until that happens you will have to limit yourself to and in your Java code.
 
Amit Sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
now check it my compiler still giving 4 errors. 2 errors are about " cant resolve symbol ob ". 1 error is " class MI should be declared abstract because it doesnot define meth2() ". and one is about " illegal start of expression at line " public void meth1(){ System.out.println("Method of A and a is:" + a);} "

interface A{
void meth1();
int a=5;
}
interface B{
void meth2();
int b=9;
}

class MI implements A,B{
public static void main(String args[]){

public void meth1(){ System.out.println("Method of A and a is:" + a);}
public void meth2(){ System.out.println("Method of B and b is:" + b);}

MI ob=new MI();
ob.meth1();
ob.meth2();
}
}

now isnt it like
 
Srivatsan santhanam
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do this:

interface A{
void meth1();
int a=5;
}

interface B{
void meth2();
int b=9;
}

public class MI implements A,B{

public void meth1(){
System.out.println("Method of A and a is:" + a);
}
public void meth2(){
System.out.println("Method of B and b is:" + b);
}

public static void main(String args[]){



MI ob=new MI();
ob.meth1();
ob.meth2();
}
}
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amit Arya:
now check it my compiler still giving 4 errors.


Well, yes. Of the two errors I pointed out -- one major, one minor -- you fixed only the minor one.
 
Amit Sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx very much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic