Question regd Inheritance Concept in 00 design

In Inheritance,when a subclass extends a Superclass,
the subclass is a specialized version of the superclass.Right?
class B extends A{
So,B is a specialized version of A.
Supposing that class B also implements an Interface:
class B extends A implements iFace{
So now:
Is B a specialized version of class A or a specialized version of an interface?
Please can anyone answer?

Both. You can treat it as class B, class A or
interface iFace.
This is how you get multiple interface inheritancein
Java.Agree on the implmentation, disagree on the theory.
B is a specialized version of A, but the interface is
more a facet of B.No. In "class B extends A implements C" B is-a C just as it is-a A.
For instance, a suburu imprezza is a specialized form
of a car - but when my wife's brother add a load of
rubbish to it, these are interfaces that it is
implementing. It might be implementing the
'SillyExpensiveAlloyWheels' interfaceThat's a poor design. You wouldn't have a care implement an interface for it's accessories as it doesn't make sense to say a particular type of care is-a SillyExpensiveAlloyWheels (ignoring the singular/plural mismatch).
Look at the Collections framework.
LinkedList is a list. It is a Collection. It is a Serializable. It is a Cloneable. It is an Object.
An interface that a class implements is not just a "facet" of that class.

Similar Messages

  • Question regd Inheritance. Please read

    In Inheritance,when a subclass extends a Superclass,
    the subclass is a specialized version of the superclass.Right?
    class B extends A{
    So,B is a specialized version of A.
    Supposing that class B also implements an Interface:
    class B extends A implements iFace{
    So now:
    Is B a specialized version of class A or a specialized version of an interface?
    Please can anyone answer?

    nope ist not a specialization od the interface. there right terminus would be class A is an implementation of the interface.
    interfaces have no behavoir, the are more sort of a method template which has to be implemented by another class. so something that has no behavoit cannot be specialized.

  • Log4j level inheritance concept doubt

    log.properties file
    log4j.debug=true
    log4j.rootLogger=ERROR, A1
    log4j.appender.A1=org.apache.log4j.ConsoleAppender
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=%m%n
    log4j.logger.logging.basics=WARN, cs3
    log4j.appender.cs3=org.apache.log4j.RollingFileAppender
    log4j.appender.cs3.layout=org.apache.log4j.PatternLayout
    log4j.appender.cs3.File=c:\\logas.txt
    log4j.appender.cs3.layout.ConversionPattern=%m%n
    log4j.appender.cs3.MaxFileSize=100KB
    log4j.appender.cs3.MaxBackupIndex=1
    log4j.additivity.com.durasoft.logging=false
    log4j.logger.RAM=INHERITED, B1
    log4j.appender.B1=org.apache.log4j.RollingFileAppender
    log4j.appender.B1.layout=org.apache.log4j.PatternLayout
    log4j.appender.B1.File=c:\\trylog.txt
    log4j.appender.B1.layout.ConversionPattern=%m%n
    log4j.appender.B1.MaxFileSize=100KB
    log4j.appender.B1.MaxBackupIndex=1
    package logging.basics;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.Properties;
    import org.apache.log4j.BasicConfigurator;
    import org.apache.log4j.FileAppender;
    import org.apache.log4j.Logger;
    import org.apache.log4j.PatternLayout;
    import org.apache.log4j.PropertyConfigurator;
    import org.apache.log4j.spi.RootLogger;
    public class LogBasics
         public static void main(String[] args) throws IOException
              Properties prop = new Properties();
              FileInputStream stream = new  FileInputStream("logging\\Resources\\log.properties");
              prop.load(stream);
              PropertyConfigurator.configure(prop);
              Logger temp = Logger.getLogger("RAM");
              RootLogger root = (RootLogger)                     Logger.getRootLogger();
              temp.error("h1i"); 
              temp.warn("hel1lo");
    }Refering to above code and properties file(in bold font), the logger named "RAM" didnt inherit from logging.basics package(which it lies), but inherits only from root, even though level and appenders for logging.basics package is specified in properties file.
    I doubt, because according to level inheritance concept, the logger must inherit from parent level(assuming parent is not null).
    Here parent ,is logging.basics for LogBasics class,so RAM logger must inherit from logging.basics as logging.basics is defined in properties file.
    But,its not happening?Why it is so?
    2) also please explain me what getLogger does when configured using property file
    Thank you.

    phanikrishnait wrote:
    Hai
    I have 3 class class A,B,C in multi level as below the method present in class A should only be accessed in A and B .Should not be visible in C and notaccessible for C class object.Java does not support that in general. In this specific case, if A and B are in the same package, and C is in a different package, and the method in question has package-private access level (not public, private, or protected).
    However, if you're doing this, you almost certainly have a design flaw. My guess is you're trying to use inheritance for code sharing, which is not what it's for.

  • Question regarding Inheritance.Please HELP

    A question regarding Inheritance
    Look at the following code:
    class Tree{}
    class Pine extends Tree{}
    class Oak extends Tree{}
    public class Forest{
    public static void main(String args[]){
      Tree tree = new Pine();
      if( tree instanceof Pine )
      System.out.println( "Pine" );
      if( tree instanceof Tree )
      System.out.println( "Tree" );
      if( tree instanceof Oak )
      System.out.println( "Oak" );
      else System.out.println( "Oops" );
    }If I run this,I get the output of
    Pine
    Oak
    Oops
    My question is:
    How can Tree be an instance of Pine.? Instead Pine is an instance of Tree isnt it?

    The "instanceof" operator checks whether an object is an instance of a class. The object you have is an instance of the class Pine because you created it with "new Pine()," and "instanceof" only confirms this fact: "yes, it's a pine."
    If you changed "new Pine()" to "new Tree()" or "new Oak()" you would get different output because then the object you create is not an instance of Pine anymore.
    If you wonder about the variable type, it doesn't matter, you could have written "Object tree = new Pine()" and get the same result.

  • One very basic question about inheritance

    One very basic question about inheritance.
    Why we need inheritance?
    the benefit of inheritance also achieve by creating instance of base class using it in other class instead of extending the base class.
    Can any one please explain why we are using inheritance instead of creating object of base class????

    SumitThokal wrote:
    One very basic question about inheritance.
    Why we need inheritance?
    the benefit of inheritance also achieve by creating instance of base class using it in other class instead of extending the base class.
    Can any one please explain why we are using inheritance instead of creating object of base class????What did you find out when you looked on Google?
    One example of inheritance comes in the form of a vehicle. Each vehicle has similarities however they differ in their own retrospect. A car is not a bus, a bus is not a truck, and a truck is not a motorbike. If you can define the similarities between these vehicles then you have a class in which you can extend into either of the previous mentioned vehicles. Resulting in a reusable class, dramatically reduces the size of code, creates a single point of definition, increases maintainability, you name it.
    In short there are thousands of benefits from using inheritance, listing the benefits could take a while. A quick Google search should give you a few hundred k if not million links to read.
    Mel

  • A question about inheritance and overwriting

    Hello,
    My question is a bit complicated, so let's first explain the situation with a little pseudo code:
    class A {...}
    class B extends A{...}
    class C extends B {...}
    class D extends C {...}
    class E extends B {...}
    class F {
      ArrayList objects; // contains only objects of classes A to E
      void updateObjects() {
        for(int i = 0; i < objects.size(); i++)
          A object = (A) objects.get(i); // A as superclass
         update(A);
      void update(A object) { ... }
      void update(B object) { ... }
      void update(D object) { ... }
    }My question now:
    For all objects in the objects list the update(? object) method is called. Is it now called with parameter class A each time because the object was casted to A before, or is Java looking for the best fitting routine depending on the objects real class?
    Regards,
    Kai

    Why extends is evil
    Improve your code by replacing concrete base classes with interfaces
    Summary
    Most good designers avoid implementation inheritance (the extends relationship) like the plague. As much as 80 percent of your code should be written entirely in terms of interfaces, not concrete base classes. The Gang of Four Design Patterns book, in fact, is largely about how to replace implementation inheritance with interface inheritance. This article describes why designers have such odd beliefs. (2,300 words; August 1, 2003)
    By Allen Holub
    http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html
    Reveal the magic behind subtype polymorphism
    Behold polymorphism from a type-oriented point of view
    http://www.javaworld.com/javaworld/jw-04-2001/jw-0413-polymorph_p.html
    Summary
    Java developers all too often associate the term polymorphism with an object's ability to magically execute correct method behavior at appropriate points in a program. That behavior is usually associated with overriding inherited class method implementations. However, a careful examination of polymorphism demystifies the magic and reveals that polymorphic behavior is best understood in terms of type, rather than as dependent on overriding implementation inheritance. That understanding allows developers to fully take advantage of polymorphism. (3,600 words) By Wm. Paul Rogers
    multiple inheritance and interfaces
    http://www.javaworld.com/javaqa/2002-07/02-qa-0719-multinheritance.html
    http://java.sun.com/docs/books/tutorial/java/interpack/interfaceDef.html
    http://www.artima.com/intv/abcs.html
    http://www.artima.com/designtechniques/interfaces.html
    http://www.javaworld.com/javaqa/2001-03/02-qa-0323-diamond_p.html
    http://csis.pace.edu/~bergin/patterns/multipleinheritance.html
    http://www.cs.rice.edu/~cork/teachjava/2002/notes/current/node48.html
    http://www.cyberdyne-object-sys.com/oofaq2/DynInh.htm
    http://www.gotw.ca/gotw/037.htm
    http://www.javajunkies.org/index.pl?lastnode_id=2826&node_id=2842
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=1&t=001588
    http://pbl.cc.gatech.edu/cs170/75
    Downcasting and run-time
    http://www.codeguru.com/java/tij/tij0083.shtml
    type identification
    Since you lose the specific type information via an upcast (moving up the inheritance hierarchy), it makes sense that to retrieve the type information ? that is, to move back down the inheritance hierarchy ? you use a downcast. However, you know an upcast is always safe; the base class cannot have a bigger interface than the derived class, therefore every message you send through the base class interface is guaranteed to be accepted. But with a downcast, you don?t really know that a shape (for example) is actually a circle. It could instead be a triangle or square or some other type.
    To solve this problem there must be some way to guarantee that a downcast is correct, so you won?t accidentally cast to the wrong type and then send a message that the object can?t accept. This would be quite unsafe.
    In some languages (like C++) you must perform a special operation in order to get a type-safe downcast, but in Java every cast is checked! So even though it looks like you?re just performing an ordinary parenthesized cast, at run time this cast is checked to ensure that it is in fact the type you think it is. If it isn?t, you get a ClassCastException. This act of checking types at run time is called run-time type identification (RTTI). The following example demonstrates the behavior of RTTI:
    //: RTTI.java
    // Downcasting & Run-Time Type
    // Identification (RTTI)
    import java.util.*;
    class Useful {
    public void f() {}
    public void g() {}
    class MoreUseful extends Useful {
    public void f() {}
    public void g() {}
    public void u() {}
    public void v() {}
    public void w() {}
    public class RTTI {
    public static void main(String[] args) {
    Useful[] x = {
    new Useful(),
    new MoreUseful()
    x[0].f();
    x[1].g();
    // Compile-time: method not found in Useful:
    //! x[1].u();
    ((MoreUseful)x[1]).u(); // Downcast/RTTI
    ((MoreUseful)x[0]).u(); // Exception thrown
    } ///:~
    As in the diagram, MoreUseful extends the interface of Useful. But since it?s inherited, it can also be upcast to a Useful. You can see this happening in the initialization of the array x in main( ). Since both objects in the array are of class Useful, you can send the f( ) and g( ) methods to both, and if you try to call u( ) (which exists only in MoreUseful) you?ll get a compile-time error message.
    If you want to access the extended interface of a MoreUseful object, you can try to downcast. If it?s the correct type, it will be successful. Otherwise, you?ll get a ClassCastException. You don?t need to write any special code for this exception, since it indicates a programmer error that could happen anywhere in a program.
    There?s more to RTTI than a simple cast. For example, there?s a way to see what type you?re dealing with before you try to downcast it. All of Chapter 11 is devoted to the study of different aspects of Java run-time type identification.
    One common principle used to determine when inheritence is being applied correctly is the Liskov Substitution Principle (LSP). This states that an instance of a subclass should be substitutible for an instance of the base class in all circumstances. If not, then it is generally inappropriate to use inheritence - or at least not without properly re-distributing responsibilities across your classes.
    Another common mistake with inheritence are definitions like Employee and Customer as subclasses of People (or whatever). In these cases, it is generally better to employ the Party-Roll pattern where a Person and an Organization or types of Party and a party can be associated with other entities via separate Role classes of which Employee and Customer are two examples.

  • Question about view/controller/nib class design

    Assume you need to make an application with, let's say, 15 different views in total. There are two extreme design choices you can use to implement the app:
    1) Every single view has its own view controller and a nib file. Thus you end up with 15 controller classes and 15 nib files (and possibly a bunch of view classes if any of your views needs to be somehow specialized).
    2) You have only one controller which manages all the views, and one nib file from which they are loaded.
    AFAIK Apple and many books recommend going purely with option #1. However, going with this often results in needless complexity, large amounts of classes (and nib files) to be managed and complicated class dependencies, especially if some of the views (and thus their controllers) interact with each other or share something (something which would be greatly simplified if all these related views were handled by one single controller class).
    Option #2 also usually ends up being very complex. The major problem is that the single controller will often end up being enormous, handling tons of different (and usually unrelated) things (which is just outright bad design). This is seldom a good design, unless your application consists of only a few views which are closely related to each other (and thus it makes sense for one single controller class to handle them).
    (Option #2 also breaks the strictest interpretation of the MVC pattern, but that's not really something I'm concerned about. I'm concerned about simple design, not about following a programming pattern to the letter.)
    A design somewhere in between the two extremes often seems to be the best approach. However, since I don't have decades of Cocoa programming experience, I would like to hear some opinions about this subject matter from people with more experience on that subject. (I do have object-oriented programming experience, but I have only relatively recently started programming for the iPhone and thus Cocoa and its design patterns are relatively new to me, so I'm still learning.)

    Somehow I get the feeling that my question was slightly misunderstood.
    I was not asking "which one of these two designs do you think is better, option #1 or option #2?" I already said in my original post that option #2 is bad design (unless your application consists of just one or two views). That's not the issue.
    The issue is that from my own experience trying to adhere very strictly to the "every single view must have its own view controller and nib file" often results in needless complexity. Of course this is not always the case, but sometimes you end up having controller classes which perform very similar, if not even the exact same actions, resulting in code repetition. (An OO'ish solution to this problem would be to have a common base class for these view controllers where the common functionality has been grouped, but this often just adds to the overall complexity of the class hierarchy rather than alleviating it.)
    As an example, let's assume that you have a set of help screens (for example one help screen for each major feature of the app) and a view where you can select which help view to show. Every one of these views has, for example, a button to immediately exit the help system. If you had one single controller class managing these views, this becomes simpler: The controller can switch between any of the views and the buttons of each view (most of them doing the same things) can call back actions on this controller (eg. to return to the help selection or to exit the help screen completely). These help screens don't necessarily have any functionality of their own, so it's questionable what do they would need view controllers of their own. These view controllers would basically be empty because there's nothing special for them to do.
    View controllers might make it easy to use the navigation controller class, but the navigation controller is suitable mainly for utility apps but often not for things like games. (And if you need animated transitions between views, that can be implemented using the UIView animation features.)
    I also have hard time seeing the advantages of adhering strictly to the MVC pattern. The MVC pattern is useful in things like web servers, where MVC adds flexibility. The controller acts as a mediator between the database and the user interface, and it does so in such an abstract way that either one can be easily changed (eg. the "view", which normally outputs HTML, could be easily changed to a different "view" which outputs a PDF or even plain text, all this without having to touch the controller or the model at all). However, I'm not seeing the advantages of the MVC pattern in an iPhone app. It provides a type of class design, but why is it better than some other class design? It's not like the input and output formats of the app need to be changed on the fly (which is one advantage of a well-designed program using the MVC pattern).

  • Question about XSL Mapper in BPEL designer

    Hi,
    I have a question regarding the XSL mapper within JDeveloper BPEL Designer.
    Scenario:
    Consider
    1. Source xsd with 3 attributes
    2. Target xsd with 5 attributes
    An XSL mapping is defined for 3 source attributes to the corresponding target attributes.
    The attributes remaining on the target side (2 attributes) are NOT mapped.
    Now test the mapper using the in-built test tool
    (by right clicking on the xsl editor screen).
    The mapper generates a test-xml on the source side and its corresponding transformed xml on the target side.
    Now,
    If i click on "Validate" in the source side, it says "XML is Valid"
    If i click on "Validate" in the target side, it says "XML is NOT Valid" (because the 2 un-mapped attributes are not apprearing the target xml)
    My question is
    Is it an expected behaviour that if an attribute is not mapped, an empty tag <attribute/> is not generated for this attribute in the target xml. If so, wouldn't the target xml be invalid with respect to the target xsd.
    Thanks
    Antony

    I believe by default xml validation is set to false for a BPEL Domain. I am not sure whether setting this to true will cause your process to error out after the transformation or if it only validates inbound and outbound messages.

  • I have A question about Adobe creative Suite 3 Design Premium, and what it comes with..

    My boyfriend works for a office furniture company building and tearing down office furniture. Today one of the people who worked at the company he was tearing down told him he could take any of the programs there as they had no use for them. So he took the Adobe Creative Suite 3 Design Premium as well as mac OSX Leopard, thinking I would like to use them. But I have a PC.
    My question is what comes with the Adobe Creative Suite 3 Design Premium? Since I can not use it, I thought I could sell it, but do not want to do so if I do not have everything it comes with or needs. What I have is three disc's, in the case. There is the application, the content, and the video workshop. There is no booklet or anything with it. If anyone could answer my question, I would really appreciate it. I dont want to sell it to someone and get in any trouble for it not having what its supposed to.
    Thank you for your time and help.

    Firstly, the CS3 Design Prem comes with Photoshop Extended CS3, Illustrator CS3, InDesign CS3, Dreamweaver CS3, Acrobat Pro 8 as well as Bridge and and Vesion Cue.
    Secondly, has the packaging been opened? If so, it could still be installed on a PC or rather Macintosh somewhere. If so, this makes it a trickier proposition with regards to installing it yourself or selling it on.
    Don't quote me on this, but if the software is fresh and unopened or has been deactivated, you could upgrade to Design Prem CS4 Mac and then crossgrade to Design Prem Windows. Don't know if it's possible to crossgrade and upgrade in one fell swoop from Mac to Win. I suspect not - but will be happy to be proven wrong.
    Hope this helps.
    Ian

  • Important query regd Inheritance.Urgent help please

    Hi,
    I have a query regarding regarding Inheritance
    This is the structure:
    Superclass: Object
    Subclass ListItem extends Object
    Subclass HandleListItem extends ListItem
    My question is:
    Can ListItem be an instance of HandleListItem??

    can ListItem be an instance of HandleListItem??yes - a variable typed as a ListItem can hold an instance of HandleListItem
    ie
    1) some ListItems are HandleListItems
    2) but not all ListItems are HandleListItems
    3) a HandleListItem is always a ListItem

  • Inheritance Concept Explanation

    Hi,
    Java does not support multiple inheritence (atleast extending multiple classes).
    I wanted to know why java has come up with such idea which violates OOPS concept?
    I know that there can be confliction with overriding methods with same name and signature from different classes. But this might occur once in centuries cases, and not even that. Then why java has ommited such a beautiful concept?
    Definitely there has to be some other reason.
    Please discuss on it.
    Thanks and regards
    Gopal Krishan Sharma
    [email protected]
    [email protected]

    > i have been taught that think of java as the
    implementers of OOPS...
    Not by a long shot. OOP predates Java by roughly thirty years.
    > Tell me what could be the possible harm in this case...
    -- BEGIN QUOTE
    Interfaces and the 'diamond problem'
    One justification of interfaces that I had heard early on was that they solved the "diamond problem" of traditional multiple inheritance. The diamond problem is an ambiguity that can occur when a class multiply inherits from two classes that both descend from a common superclass. For example, in Michael Crichton's novel Jurassic Park, scientists combine dinosaur DNA with DNA from modern frogs to get an animal that resembled a dinosaur but in some ways acted like a frog. At the end of the novel, the heros of the story stumble on dinosaur eggs. The dinosaurs, which were all created female to prevent fraternization in the wild, were reproducing. Chrichton attributed this miracle of love to the snippets of frog DNA the scientists had used to fill in missing pieces of the dinosaur DNA. In frog populations dominated by one sex, Chrichton says, some frogs of the dominant sex may spontaneously change their sex. (Although this seems like a good thing for the survival of the frog species, it must be terribly confusing for the individual frogs involved.) The dinosaurs in Jurassic Park had inadvertently inherited this spontaneous sex-change behavior from their frog ancestry, with tragic consequences.
    This Jurassic Park scenario potentially could be represented by the following inheritance hierarchy:
              Animal
           Frog   Dinosaur
             FrogasaurThe diamond problem can arise in inheritance hierarchies like the one shown in Figure 1. In fact, the diamond problem gets its name from the diamond shape of such an inheritance hierarchy. One way the diamond problem can arise in the Jurassic Park hierarchy is if both Dinosaur and Frog, but not Frogosaur, override a method declared in Animal. Here's what the code might look like if Java supported traditional multiple inheritance:
    abstract class Animal {
        abstract void talk();
    class Frog extends Animal {
        void talk() {
            System.out.println("Ribit, ribit.");
    class Dinosaur extends Animal {
        void talk() {
            System.out.println("Oh I'm a dinosaur and I'm OK...");
    // (This won't compile, of course, because Java
    // only supports single inheritance.)
    class Frogosaur extends Frog, Dinosaur {
    }The diamond problem rears its ugly head when someone tries to invoke talk() on a Frogosaur object from an Animal reference, as in:
    Animal animal = new Frogosaur();
    animal.talk();Because of the ambiguity caused by the diamond problem, it isn't clear whether the runtime system should invoke Frog's or Dinosaur's implementation of talk(). Will a Frogosaur croak "Ribbit, Ribbit." or sing "Oh, I'm a dinosaur and I'm okay..."?
    The diamond problem would also arise if Animal had declared a public instance variable, which Frogosaur would then have inherited from both Dinosaur and Frog. When referring to this variable in a Frogosaur object, which copy of the variable -- Frog's or Dinosaur's -- would be selected? Or, perhaps, would there be only one copy of the variable in a Frogosaur object?
    In Java, interfaces solve all these ambiguities caused by the diamond problem. Through interfaces, Java allows multiple inheritance of interface but not of implementation. Implementation, which includes instance variables and method implementations, is always singly inherited. As a result, confusion will never arise in Java over which inherited instance variable or method implementation to use.
    -- END QUOTE
    http://www.javaworld.com/javaworld/jw-12-1998/jw-12-techniques.html

  • HI  question on inheritance

    Why abap does not support multiple inheritance

    shanthi,
    check the below threads.... same question discussed before also
    multiple inheritance
    Re: Does ABAP Obj. supports multiple or multilevel inheritence
    If you find what ever u r looking for please close the thread...... if u need further info lemme know
    ~~Guduri

  • Question about the concept of RMI reverse calls.

    Hello guys.
    I'd appreciate if someone could clarify something to me. As far as I understand , RMI reverse call in concept, is the mean thought witch a server can remotely call a method belonging to the client.
    I've done that like this: the client called a method from to the server(classic rmi) , method that had the particularity to received as a parameter an instance of a serialized .class belonging to client. Through that received remote object it seems the server can call specific methods belonging to the client .class.
    I'm not sure it's the correct way to do reverse calls, but what puzzles me is that shouldn't the server be able to call a client method without first needing to receive that instance of the client's .class and implicitly being dependent on that client initial call (maybe to get that .class in a different way)?

    I'm not sure it's the correct way to do reverse callsIt's not. If the object passed to the server is serializable, the server can call methods on it, but they will execute at the server.
    The object you pass to the server must be an exported remote object. Then the server callbacks will execute at the client.
    but what puzzles me is that shouldn't the server be able to call a client method without first needing to receive that instance of the client's .classNo, why?
    and implicitly being dependent on that client initial call (maybe to get that .class in a different way)?When you get the exported remote object part right, the remote method via which the client passes the callback to the server will declare the callback as a remote interface, not as the implementing class at the client.

  • A little question about inheritance

    Can someone explain this to me?
    I have been reading about inheritance in Java. As I understand it when you extend a class, every method gets "copied" to the subclass. If this is so, how come this doesn't work?
    class inherit {
        int number;
        public inherit(){
            number = 0;
        public inherit(int n){
            number = n;
    class inherit2 extends inherit{
        public inherit2(int n, int p){
            number = n*p;
    class example{
        public static void main(String args[]){
            inherit2 obj = new inherit2();
    }What I try to do here is to extend the class inherit with inherit2. Now the obj Object is of inherit2 class and as such, it should inherit the constructor without parameters in the inherit class or shouldn't it ??? If not, then should I rewrite all the constructors which are the same and then add the new ones??

    I believe you were asking why SubClass doesn't have the "default" constructor... after all, shouldn't SubClass just have all the contents of SuperClass copy-pasted into it? Not exacly. ;)
    (code below... if you'd like, you can skip the first bit, start at the code, and work your way down... depending on if you just started, the next bit may confuse rather than help)
    Constructors are special... interfaces don't specify them, and subclasses don't inherit them. There are many cases where you may not want your subclass to display a constructor from it's superclass. I know this sounds like I'm saying "there are many cases where you won't want a subclass to act exactly like a superclass, and then some (extend their functionality)", but its not, because constructors aren't how an object acts, they're how an object gets created.
    As mlk said, the compiler will automatically create a default constructor, but not if there is already a constructor defined. So, unfortunatley for you, there wont be a default constructor made for SubClass that you could use to create it.
    class SuperClass { //formerly inherit
    int number;
    public SuperClass () { //default constructor
    number = 0;
    public SuperClass (int n) {
    number = n;
    class SubClass extends SuperClass { //formerly inherit2
    //DEFAULT CONSTRUCTOR, public SubClass() WILL NOT BE ADDED BY COMPILER
    public SubClass (int n, int p) {
    number = n*p;
    class Example {
    public static void main(String [] args) {
    //attempted use of default constructor
    //on a default constructorless subclass!
    SubClass testSubClass = new SubClass();
    If you're still at a loss, just remember: "Constructors aren't copy-pasted down from the superclass into the subclass!" and "Default constructors aren't added in if you add your own constructor in" :)
    To get it to work, you'd have to add the constructor you used in main to SubClass (like doopsterus did with inheritedClass), or use the constructor you defined in SubClass for when you make a new one in main:
    inherit2 obj = new inherit2(3,4);
    Hope that cleared things up further, if needed. By the way, you should consider naming your classes as a NounStartingWithACapital, and only methods as a verbStartingWithALowercase

  • Question - new to BO Data Services Designer - how to automatically transform varchar column data to upper(varchar) across all columns in a table?

    Hello -
    New user to BO Data Services Designer. Company is using Data Services Version 12.2.
    I have many tables that all need the same transformation- converting varchars fields to upper(varchar) fields
    Example:
    I have a table called Items. It has 40 columns, 25 of which are of type varchar.
    What I have been doing is ....
    I make the Item table as the source table then create a Query transform that is then attached to a new target table called - ITEMS_Production.
    I can manually drag and drop columns from the source table to the query and then in the mapping area I can manually type in upper(table_name.column_name) or select the upper function and then select the table.column name from the function drop down list.
    Obviously, I want to do this quicker as I have to do this for lots and lots of tables.
    How can set up Data Services so that I can drag and drop an upper transform quickly and easily or automate this process.
    I also know Python-Java so am happy to script something if need be.
    the logic would be something like -
    if there is a column with a type varchar, add the upper() transformation to column. Go to next column.
    Excited to be using this new tool-
    Thanks in advance.
    Ray

    Use the DS Workbench.

Maybe you are looking for

  • Audigy 4 external hub probl

    Hi, my audigy 4 pro external hub has stopped working completely. The power light doesn't turn on. I have reinstalled the drivers several times, and I get an error message, something about an NT failed or invalid handler I think? Will the external hub

  • Created a Form in Acrobat 9 pro and in LiveCyle. Images are blank in Acrobat Reader !!!Can you Help?

    I wrote a manual using MS Word on Vista 64 bit I have images in the manual. When I open the File in Acrobat 9 Pro, the images are displayed. BUT, when I opne it in ACrobat reader, the images are black boxes ! Would you be kind to help me solve this m

  • Differences between mcp and mcp t sound

    this is all sound sound info direct from a man at nvidia who knows PLEASE NOTE ONLY MCP2-T BOARD MSI DO AT THE MOMMENT IS THE K7N2G-ILSR The MCP has no hardware support for audio of any kind, period. Windows and the CPU do all the audio work on that

  • Can the Read Out Loud tool read tooltips?

    Hello, I have created a PDF with a text form field where the user will enter his/her name and then print a course completion certificate.  I have named the text form field and added a tooltip. 1.  It looks fine in Form Edit mode but there is text tha

  • Store documents in local machine of file system not in sap dms

    Hi, Can i store documents in local machine not in sap Database . Client  will not use content server for storing document. so how to store document in local file system n how to configure ? please help. Dipak.