aspose file tools*
The moose likes Java in General and the fly likes plz tell what is wrong in it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "plz tell what is wrong in it" Watch "plz tell what is wrong in it" New topic
Author

plz tell what is wrong in it

Amit Sharma
Ranch Hand

Joined: Nov 22, 2005
Posts: 87
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();
}
}


Amit Sharma SCJP 1.4, SCWCD 5, OCUP-100(UML)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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 ]

[Jess in Action][AskingGoodQuestions]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
Amit Sharma
Ranch Hand

Joined: Nov 22, 2005
Posts: 87
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

Joined: Jan 04, 2006
Posts: 23
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();
}
}


Java Objects passed by Reference ?? -> you are a failure !!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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

Joined: Nov 22, 2005
Posts: 87
Thanx very much
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: plz tell what is wrong in it