Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: java:29:error:<identifier> expected,java:29:error:invalid method declaration; return type required

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java:29:error:<identifier> expected,java:29:error:invalid method declaration; return type required

    abstract class A
    {
    double x,y;
    A(double a,double B)
    {
    x=a;y=b;
    }
    abstract double m1()
    {
    }
    class B extends A
    {
    B(double a,double b)
    {
    super(a,b);
    }
    double m1()
    {
    System.out.println("Inside B");
    return x*y;
    }
    }
    class C extends A
    {
    C(double a,double b)
    {
    super(a,b);
    }
    double void m1();
    {
    System.out.println("Inside C");
    }
    double p=x*y;
    {
    System.out.println(p);
    }
    }
    class Demo
    {
    public static void main(String args[])
    {
    B.obj=new B(5,5);
    C.obj=new C(15,15);
    System.out.println("B area is"+b.m1());
    System.out.println("C area is"+c.m1());
    }
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: java:29:error:<identifier> expected,java:29:error:invalid method declaration; return type required

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    Be sure the code is properly indented.

    Also copy the full text of the error messages and paste it here. It should show where the errors happened
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: java:29:error:<identifier> expected,java:29:error:invalid method declaration; return type required

    Welcome to the forum! If you haven't already (apparently not), please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

Similar Threads

  1. Error: Invalid method declaration; return type required. Related to JFrames.
    By Pakupakuman in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 26th, 2012, 05:47 PM
  2. error Identifier expected?
    By chandresh in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 15th, 2012, 02:34 AM
  3. Replies: 4
    Last Post: February 26th, 2012, 05:36 PM
  4. error: invalid meyhod declaration
    By iswan in forum AWT / Java Swing
    Replies: 0
    Last Post: September 30th, 2011, 08:03 PM
  5. error: This method must return a result of type int
    By J05HYYY in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 13th, 2011, 05:26 PM