Abstract class extends other class?

What happens when a abstract class extends other class?
How can we use the abstract class late in other class?
Why do we need an abstract class that extends other class?
for example:-
public abstract class ABC extends EFG {
public class EFG{
private String name="";
private int rollno="";
private void setName(int name)
this.name=name;
private String getName()
return this.name;
}

shafiur wrote:
What happens when a abstract class extends other class?Nothing special. You have defined an abstract class.
How can we use the abstract class late in other class?Define "Late". What "other class"?
Why do we need an abstract class that extends other class?Because it can be useful to define one.

Similar Messages

  • Calling a object of class from other class's function with in a package

    Hello Sir,
    I have a package.package have two classes.I want to use object of one class in function of another class of this same package.
    Like that:
    one.java
    package co;
    public class one
    private String aa="Vijay";  //something like
    }main.java:
    package co;
    import java.util.Stack;
    public class main extends Stack
    public void show(one obj)
    push(obj);
    public static void main(String args[])
    main oo=new main();
    }when I compile main class, Its not compile.
    Its give error.can not resolve symbol:
    symbol: class one
    location: class co.main
    public void show(one obj)
                              ^Please help How that compile "Calling a object of class from other class's function with in a package" beacuse I want to use this funda in an application

    kumar.vijaydahiya wrote:
    .It is set in environment variable.path=C:\bea\jdk141_02\bin;.,C:\oraclexe\app\oracle\product\10.2.0\server\bin;. command is:
    c:\Core\co\javac one.javaIts compiled already.
    c:\Core\co\javac main.javaBut it give error.
    Both java classes in co package.Okay, open a command prompt and execute these two commands:
    // to compile both classes:
    javac -cp c:\Core c:\Core\co\*.java
    // to run your main-class:
    java -cp c:\Core co.main

  • LoadClass    (error loading a class which extends other class  at run-time)

    Hey!
    I'm using the Reflection API
    I load a class called 'SubClass' which exists in a directory called 'subdir' at run-time from my program
    CustomClassLoader loader = new CustomClassLoader();
    Class classRef = loader.loadClass("SubClass");
    class CustomClassLoader extends ClassLoader. I have defined 'findClass(String className)' method in CustomClassLoader.
    This is what 'findClass(String className)' returns:
    defineClass (className,byteArray,0,byteArray.length);
    'byteArray' is of type byte[] and has the contents of subdir/SubClass.
    the problem:
    The program runs fine if SubClass does not extend any class.
    If however, SubClass extends another class, the program throws a NoClassDefFoundError. How is it conceptually different?
    Help appreciated in Advance..
    Thanks!

    Because i'm a newbie to the Reflection thing, i'm notI don't see reflection anywhere. All I see is class loading.
    sure what role does the superclass play when i'm
    trying to load the derived class and how to get away
    with the errorWell... hint: all the superclass's stuff is not copied into the subclass.
    I am quite sure it fails to load the superclass because of classpath issues.

  • Package.Class extends Package.Class ??

    Is there any way I can make a class in a package extend another class in the same package://---- File: JrcCode1.java
    package jrc;
    public class JrcCode1 {
      public JrcCode1() {
        System.out.println("JrcCode1");
    //---- File: JrcCode2.java
    package jrc;
    public class JrcCode2 extends JrcCode1 {     //cannot resolve symbol, class JrcCode1
      public JrcCode2() {
        super();
        System.out.println("JrcCode2");
    }Thanks,
    James

    The current directory is not automatically in the classpath.
    You have to set it up that way. That may be your problemI have tried doing this, and it's still the same! The first code compiles but the second code fails:
    javac -sourcepath . -classpath . JrcCode1.java
    javac -sourcepath . -classpath . JrcCode2.java
    Try extending jrc.JrcCode1. It might work, but i didnt test it outI have tried this, and it still fails:
    JrcCode2.java:3: cannot resolve symbol
    symbol : class JrcCode1
    location: package jrc
    public class JrcCode2 extends jrc.JrcCode1 {
    Any other ideas?
    Thanks alot!
    James

  • Transfer asset from on class to other class without changeing asset no.

    Dear All,
    I have a requirement.
    I want to transfer some assets from one asset class to other asset class, but I do not want to change the asset no.
    Can you help me
    b.s.rao

    Hi,
    This is not possible.
    Pankaj,
    Your solution will not work, as you cannot maintain the same number series for both sending and receiving asset classes, even though if one is having internal number assignment and another is external number assignment.
    Ex: You cannot have 2 number range objects which includes a one asset number. In AS08 system will never accept this overlapping of asset number series.
    Correct me if i am wrong...
    Thanks,
    Srinu

  • Javac = "cannot find symbol" when compiling class referencing other classes

    I have several Java files in a directory which is declared as a package at the start of the files
    package filemanager;
    This program works perfectly in an IDE, however I'm having problems with compiling in command line.
    I have set the classpath as I understand to be right for my computer to:
    C:\Program Files\Java\jdk1.6.0_02\bin
    I can compile a class that references no other classes in this package/directory.
    However files which reference other classes bring up such errors:
    javac AllFiles.javaAllFiles.java:174: cannot find symbol
    symbol : variable Bob
    location : class filesmanager.AllFiles
    Bob.getItem(itemRef);
    Where Bob is an example of another class. Even though I can say, compile Bob on it's own as it doesnt have any such reference.
    I've tried:
    javac -cp "C:\Program Files\Java\jdk1.6.0_02\bin" AllFiles.javaThis also failed.
    Any ideas?
    Edited by: ajr87 on Feb 8, 2008 10:26 AM

    I've tried spoon_'s suggestion, but I'm still getting the error ("cannot find symbol"). Here is my code:
    File Hello/Fred.java:
    package Hello;
    public class Fred
        public int age;
        public Fred()
            this.age = 1;
    } // public class FredFile Hello/Hello.java:
    package Hello;
    public class Hello
        public static void main(String args[])
            Fred fred = new Fred();
            System.out.println("Fred is " + fred.age);
    } // public class HelloAnd here is my attempt to compile Fred.java and Hello.java:
    C:/Users/levner/programs[219]javac -cp c:\users\levner\programs\hello Hello\Fred.java
    C:/Users/levner/programs[220]javac -cp c:\users\levner\programs\hello Hello\Hello.java
    Hello\Hello.java:14: cannot find symbol
    symbol  : class Fred
    location: class Hello.Hello
            Fred fred = new Fred();
            ^
    Hello\Hello.java:14: cannot find symbol
    symbol  : class Fred
    location: class Hello.Hello
            Fred fred = new Fred();
                            ^
    2 errorsI am doing this work on a PC running Vista using javac 1.6.0_10. I've tried various combinations of upper and lower case names for the package and file names, and I always get the same errors.
    Thanks in advance for your help. David

  • Using one class into other class??

    Hey,I need to pass one class's object to another class's constructor.problem is which class I should compile first because both classes are using each other so when i compile any of these file it gives error in refering other as other file is not compiled.I am using as follows:
    package p;
    class test1
    //statements
    test2(this);
    Here is my second class:
    package p;
    class test2
    test2(test1 t)
    //some statements

    surely you can put them on one page/file and compile?? (i m just givin a suggestion, i am by no means an expert! :) )

  • Import other class from other class file

    let say, i got class student in the file name "student.class".
    my main program is school.class.
    how to import student.class into school.class so i can use student class.?
    what is the directory i had to store the 2 file?

    School.java:
    class School {
        Student a, b, c;
        public static void main(String[] args) {
            a = new Student("fred","foobar");
            b = new Student("fred","barbaz");
            c = new Student("fred","bazqux");
            System.out.println("Student a is "+a.name+" "+a.surname);
            System.out.println("Student b is "+b.name+" "+b.surname);
            System.out.println("Student c is "+c.name+" "+c.surname);
    class Student {
        String name, surname;
        public Student(String nam, String sur) {
            name = name;
            surname = sur;
    }

  • Calling a variable from main class to other class

    How do I call a variable that is initialize in the Test.java into Sub.java?
    I want to call the a, b, c that I have initialize in Test.java into Sub.java.
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    public class Test{
         public static void main(String args[]){
              int b;
              int c=1;
              int a=11;
              b = c + a;
              System.out.println(+b);
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    public class Sub{
         public void Subtraction(){
              if(a>c)
                   b = a-c;
              else if(c>a)
                   b = c-a;
              else if(a=c)
                   b = a-c;
              System.out.println(+b);
    }

    This is, and I'm sorry but I don't know how else to say this, a real big mess.
    I'll go through some (most/all) of it but honestly....
    import java.awt.*;Many will tell you that you should use specific imports and not wildcards to increase ease of reading. I am not so personally picky about this but it would help you.
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*; Don't import things you never use. It just adds confusion get rid of java.util import
    import java.lang.Object.*;Redundant. Remove it.
    import java.applet.Applet.*;Unused. get rid of it
    public class SUBOK {      Terrible class name. Please use the standard [_Java naming conventions_|http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html]
    public int a = 10;
        public static void main(String[] args) {
             SUBOK runGUI = new SUBOK();
        public SUBOK(){
             JFrame f = new JFrame("Subok");
             f.setSize(150,100);
             f.setVisible(true);
             f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
             JButton b = new JButton("Sum");
             b.setActionCommand("send");
             b.addActionListener(new Push());
             JPanel p = new JPanel();
             p.add(b);
             f.add(p);
        } Most of that is okay although not great. But I don't think you should be doing anything in Swing at all yet.
      private class Push implements ActionListener{
             public void actionPerformed(ActionEvent e){
                  if(e.getActionCommand().equals("send")){
                       int a = 12;You are aware that this a has nothing to do with your other a? right? I mean this is a method local variable in a whole other class then the other one.
                           Add i = new Add();
                           i.Add();                
        public int aValue(){
             return a;
    } Alrighty then...
    import java.lang.*;Redundant. Remove You never need to import java.lang.
    import java.awt.*;Unused. remove.
    import java.util.*;Unused remove.
    public class Add {
         SUBOK a = new SUBOK();
         int d = a.aValue(); Aiaiaiai.
      public void Add() {
             int b;
             int c = 0;
             b = d+c;
             System.out.println(b);
    }First of all do not name a method the same as a class. Second most of this class appears to be based mainly in the realm of wishful thinking. In programming, wishing that something will "just work" without understanding the basics of why and how it works does, pretty much 100% of the time, not end well.
    You need to take a number of steps back from this code, get grounded in some fundamentals and then make another attempt. I would highly recommend putting the Swing (or any other GUI) code aside for some time now. Inter-object communication is a fundamental part of OO and thus a fundamental part of Java and this code clearly shows that you don't understand it yet at all.
    Start here [_Learning The Java Language_|http://java.sun.com/docs/books/tutorial/java/index.html]
    If you have questions as you go through the tutorial do come back and ask them and someone here will be glad to help you. But in order to help you with code you have to be at a point where you understand things like variable scope, the difference between a class and an Object and how, why and what methods can be used to exchange information between two instances.

  • Help with GUI (calling one class from other class)

    Hi everybody,
    I am new at GUI and I need your help..
    I have a JPanel, named "holdAll", layout of which is set to BorderLayout. I have implemented all other JPanels in different class files. For example, I have TopPanel, LeftPanel, etc. as shown below
    LeftPanel myLeft = new LeftPanel();
    holdAll.add(myLeft, BorderLayout.WEST);
    RightPanel myRight = new RightPanel();
    holdAll.add(myRight, BorderLayout.EAST);
    TopPanel myTop = new TopPanel();
    holdAll.add(myTop, BorderLayout.NORTH);
    MiddlePanel myMiddle = new MiddlePanel();
    holdAll.add(myMiddle, BorderLayout.CENTER);
    BottomPanel myBottom = new BottomPanel();
    holdAll.add(myBottom, BorderLayout.SOUTH);
    That works well but I have difficulties in ActionListeners.. For example, in my TopPanel class I have the code below:
    public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnInsert) {
    int returnVal = fc.showOpenDialog(fc);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    myImage newImage = new myImage(file);
    System.out.println(newImage.myHashCode());
    Here, if I have upload new image, then I have to update the listImage in the LeftPanel class.. But, I could not access the lstImage object in the LeftPanel class from the actionListener event in the TopPanel class.
    What should I do? Is my design poor?

    public class TopPanel extends JPanel implements ActionListener { //it doesn't allow "extends JPanel, Observable"
    JFileChooser fc;
    JButton btnInsert;
    JButton btnDelete;
    public TopPanel() {
    setLayout(new FlowLayout());
    setBorder(BorderFactory.createBevelBorder(1, Color.WHITE, Color.GRAY));
    btnInsert = new JButton("Insert");
    btnDelete = new JButton("Delete");
    JLabel myLabel = new JLabel(" Search : ");
    JTextField txtSearch = new JTextField();
    txtSearch.setColumns(20);
    JToolBar searchToolBar = new JToolBar();
    fc = new JFileChooser();
    btnInsert.addActionListener(this);
    searchToolBar.add(btnInsert);
    searchToolBar.add(btnDelete);
    searchToolBar.add(myLabel);
    searchToolBar.add(txtSearch);
    add(searchToolBar);
    public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnInsert) {
    int returnVal = fc.showOpenDialog(fc);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    *//Here I want to send fc.GetName() to the JList in the LeftPanel*
    my LeftPanel class is below:
    public class LeftPanel extends JPanel{
    public LeftPanel(){
    this.setLayout(new BorderLayout());
    setBorder(BorderFactory.createBevelBorder(1, Color.WHITE, Color.GRAY));
    JPanel pnlButtons = new JPanel();
    JButton btnName = new JButton("Name");
    JButton btnSize = new JButton("Size");
    JButton btnDate = new JButton("Date");
    pnlButtons.add(btnName);
    pnlButtons.add(btnSize);
    pnlButtons.add(btnDate);
    pnlButtons.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    JPanel pnlImage = new JPanel();
    JList lstImage = new JList();
    lstImage.setVisible(true);
    pnlImage.add(new JScrollPane(lstImage));
    add(pnlButtons, BorderLayout.NORTH);
    add(pnlImage, BorderLayout.CENTER);
    Is there any simple way?

  • FlexiDate.class extends Date.class

    Hi, I am pleading for help with the following.
    I am trying to compile the FlexiDate class which extends from oracle.jbo.domian.Date class. The oracle.jbo.domian.Date class must contain the inner class Date$1$facClass because when I compile the FlexiDate class I receive the message "Error Type: oracle/jbo/domain/Date$facClass was not found. Both the Date and Date$facClass classes are in the same jre file which is in the classpath. What's wierd is that this error doesn't occur when I compile using Oracle Jdeveloper(Win NT) but does occur in the unix environment. Both environments are using the same JDK1.3.1 and the same libraries and classpath. Any help is much appreciated. Thanks.
    null

    Can you double-check that you have the jbodomorcl.zip archive correctly specified as part of your CLASSPATH in your compiletime environment? The class it's complaining about is in this archive.

  • Weblogic User class extends deprecated class?

    weblogic.security.acl.User extends java.security.Identity which is a
    deprecated class for Java 1.2
    I checked the 5.1 API docs, this class still extends the
    java.security.Identity. Are there any plans to update this class or if there
    is another class we should use instead of weblogic.security.acl.User ?
    Srikanth Meenakshi

    s> weblogic.security.acl.User extends java.security.Identity which is
    s> a deprecated class for Java 1.2
    This is not a problem. It's okay to use it.
         <b
    Let us pray:
    What a Great System.
    Please Do Not Crash.
    ^G^IP@P6

  • Error 1119 when class extends another class that extends movieclip

    hiya
    i came across this problem and i have no clue why it's happening. basically, consider 2 nested movieclips on the stage, something like stage -> main -> filler.  both movieclips have instance names (main and filler).
    in the library, i set main to export for actionscript, using class A:
    package {
        import flash.display.MovieClip;
        public class A extends MovieClip {     
            public function A ():void {
                trace ('construct A');
                trace (this.filler); // should trace [movieclip] etc
    it works fine. now i change it's export settings to use class B, that extends A, and it breaks:
    package {
        import flash.display.MovieClip;
        public class B extends A {
            public function B ():void {
                trace ('construct B');
    this throws an error 1119: Access of possibly undefined property filler through a reference with static type A.
    can anyone give me a hint on that, as it works with class A, but not B extending A? i understand it was meant to work?
    many thanks

    afaik, if you dont declare super(), flash will make a call for you (but best practice is to call it always).
    but i found the "solution" in another forum.
    it seems that flash implicitly generates variables if you have instance names/symbols on the stage. there is an option to disable that under publish settings -> Actionscript version -> Settings -> automatically declare stage instances. by disabling that, we were able to declare public var filler:MovieClip; on class A, and that worked.
    although, that solution doesnt look attractive to me. the other solution posted on another forum was to make calls to this ["filler"] instead of this.filler. that seems to work fine. i guess it has to do with the automatic variable generated thing.. who knows?
    i hope that helps someone else too

  • How to use method of one class in other class.

    Hi.I am new to object orient approach .I am developing a project which has a class as application .My class has it state control as another class which is notification class.I want to use my notification class method (init)in my application class method .i have also used read and write accessors vis.But i have broken lines in my code.Please help me correct it. and print screen is attached below.
    Attachments:
    Application.docx ‏143 KB

    On the left, you have wired 2 sources on the same tunnel/wire, so that's 1 broken wire.
    In the For loop, you are trying to wire a "Red" object from the first subVI to the input of the "Green" subVI, so a "Green" object. If Red is not a descendant class of Green (or share a common ancestor), it is not permitted.
    FInally, the output of the For loop, is a 1D array of "Green" objects, which is probably not the same data type as the input of the last subVI on the right (it's probably a "Green" object scalar).
    Overall, you can use the "List Errors" dialog box (Ctrl+L) to debug your code, and make exhaustive use of the contextual help (Ctrl+H) to see what is going on when focusing a broken wire.
    Regards
    Eric M. - Application Engineering Specialist
    Certified LabVIEW Architect
    Certified LabWindows™/CVI Developer

  • Calling istance class from other class

    Another step, another problem. I've declared a mySocketDelegate class that contains all the delegate methods of NetSocket and it's the delegate for my extern mySharedSocket. It works without problem, since i've to send a message to another class, in this case to RootViewController. I post the code
    #import "mySocketDelegate.h"
    #import "NetSocket.h"
    #import "GlobalValues.h"
    #import "ContactListController.h"
    #import "ProgettoTesiAppDelegate.h"
    #import "RootViewController.h"
    @implementation mySocketDelegate
    - (void)netsocketConnected:(NetSocket*)inSocket {
    - (void)netsocketDisconnected:(NetSocket*)inSocket {
    - (void)netsocket:(NetSocket*)inNetSocket dataAvailable:(unsigned)inAmount {
    if(headerRecieved){
    if(dataread == drlen && dataRecieved != nil) {
    if([dataRecieved isEqualToString:[[NSString alloc] initWithString:@"Login valido"]]){
    NSLog(@"Chiamo contactList controller");
    ContactListController *clController = [[ContactListController alloc] initWithNibName:@"ContactList" bundle:nil];
    clController.title = @"Contact List";
    [[RootViewController navigationController] pushViewController:clController animated:YES]; //THE PROBLEM IS HERE. IT RISES AN ERROR, BECAUSE
    //RootViewController is not an istance, but a class, how can i access the istance of RootViewController
    dataRecieved = [[NSMutableString alloc] init];
    } else {
    @end
    Then, the problem is there. In RootViewController i set mySocketDelegate as delegate for mySharedSocket (this work fine), then in mySocketDelegate i have to access the istance of RootViewController (it is the controller of my main view)...how to do this?
    Thank you

    I undestand the logic behind this part of code, but it stil doen't work...it rises this error:
    error:Request for memeber 'myRooViewController' in something not a structure or union
    ...and it's ok...probably the semanthic isn't right? How to access a istance variable of an istance?
    This is the code:
    mySharedSocket = [[NetSocket netsocketConnectedToHost:host port:PORT] retain];
    mySharedSocketDelegate = [[mySocketDelegate alloc] init];
    mySharedSocketDelegate.myRootViewController = self; //the error is here
    if([mySharedSocket open]){
    NSLog(@"socket opened");
    [mySharedSocket setDelegate:mySharedSocketDelegate];
    [mySharedSocket scheduleOnCurrentRunLoop];
    dataRecieved = [[NSMutableString alloc] init];

Maybe you are looking for