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 4 of 4

Thread: i have created the following code for classes, Account and SavingAcc, However, the preceding code results in compilation error. Identify the error please help me with the error? and please be more specific?

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

    Unhappy i have created the following code for classes, Account and SavingAcc, However, the preceding code results in compilation error. Identify the error please help me with the error? and please be more specific?

    public class Account {
    public void checkBal(string accNum) {
    }
    public void withdrawAmt(string accNum) {
    }
    public static void depositAmt(string accNum) {
    }
    }
    public class SavingAcc extends Account{
    public static void checkBal(string accNum){
    }
    public void withdrawAmt (string accNum) {
    }
    public void depositAmt (string accNum) {
    }
    }


  2. #2
    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: i have created the following code for classes, Account and SavingAcc, However, the preceding code results in compilation error. Identify the error please help me with the error? and please be more specific?

    Post properly indented code inside the code tags.

    Post your errors.

  3. #3
    Junior Member
    Join Date
    May 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Re: i have created the following code for classes, Account and SavingAcc, However, the preceding code results in compilation error. Identify the error please help me with the error? and please be more specific?

    i am using netbeans 8.0 this what i get ,

    run:
    java.lang.ExceptionInInitializerError
    Caused by: java.lang.RuntimeException: Uncompilable source code - class CurrentBal is public, should be declared in a file named CurrentBal.java
    at CurrentBal.<clinit>(Balances.java:16)
    Exception in thread "main" Java Result: 1
    BUILD SUCCESSFUL (total time: 2 seconds)

  4. #4
    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: i have created the following code for classes, Account and SavingAcc, However, the preceding code results in compilation error. Identify the error please help me with the error? and please be more specific?

    This is the relevant info from the error message you've posted:
    Uncompilable source code - class CurrentBal is public, should be declared in a file named CurrentBal.java
    Either move the class CurrentBal to its own file named CurrentBal.java OR remove the 'public' modifier.

Similar Threads

  1. Replies: 3
    Last Post: November 30th, 2013, 05:52 PM
  2. Replies: 4
    Last Post: January 24th, 2013, 11:20 AM
  3. Replies: 7
    Last Post: January 24th, 2013, 10:41 AM
  4. Compilation error
    By gnarkill10 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 5th, 2012, 08:15 AM
  5. Code is giving an error in console, but there are no errors apparent in the code!
    By JamEngulfer221 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 15th, 2011, 09:30 PM