• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

plz tell what is wrong in it

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
}
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx very much
 
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic