Doubt on basic  concept

Say we have a class called Animal which has a method called shout().
we have another class called Dog which has a method callled bark().
Dog class extends Animal class.
so Dog class has 2 methods now
1)shout()
2)bark()
If we declare like this
Animal a=new Animal();//valid statement
a.shout();//valid statement
Dog d=new Dog();//valid statement
d.shout();//valid statement
d.bark();//valid statement
Animal a=new Dog();
a.shout();//valid statement
a.bark();//invalid since type of reference variable is Animal
Dog d=new Animal();
why the above decalration is not valid?
Animal object has shout() method
By inheritance Dog class has both shout() and bark() methods.
So with above type of declaration d.shout() should execute.But that is wrong.
A subclass reference variable cannt point to a subclass object.I know this kind of statement.But can any one explain why?

kirn291 wrote:
Dog d=new Animal();
why the above decalration is not valid?To a Dog variable you can only assign objects which are of type Dog, and Animal isn't.
A Dog object is both of type Dog and of type Animal. This means Dog objects can be assigned to both Dog variables and Animal variables.

Similar Messages

  • Trying to understand the basic concept of object oriented programming.

    I am trying to understand the basic concept of object oriented programming.
    Object - a region of storage that define is defined by both state/behavior.
    ( An object is the actual thing that behavior affects.)
    State - Represented by a set of variables and the values they contain.
    (Is the location or movement or action that is the goal that the behavior is trying to accomplish.)
    Variables- (What does this mean?)
    Value - (What does this mean?)
    Behavior - Represented by a set of methods and the logic they implement.
    ( A set of methods that is built up to tell's the how object to change it's state. )
    Methods - A procedure that is executed when an object receives a message.
    ( A very basic comand.For example the method tells the object to move up, another method tells the method to go left. Thus making the object move up/left that combination is the behavior.)
    Class - A template from which the objects are created.
    ( I am very confused on what classes are.)
    - The definitions of the words I obtained from the "Osborne Teach Yourself Java". The () statements are how I interperate the Mechanisms (I do not know if Thats what you call them.) interact with each other. I understand my interpretation may be horribly wrong. I will incredibly appreciate all the support I may get from you.
    Thank you

    Object oriented programming is a replacement for the older idea of procedural programming (you can research procedural programming in google). As I understand it, in procedural programming, you have a step by step set of function calls to accomplish some task. Each function receives a data structure, manipulates it, and passes it to the next function. The problem with this is that each function preforms some action for the overall task and can't easily be reused by some other task. Its also harder to read the flow of what is happening with raw data structures flying all over the place.
    In object oriented programming, an object calls a function of another object and receives back, not a data structure, but another object. Objects contain a data structure that can only be accessed by its functions. An object is not so much a sub component of a bigger task, as it is a service that any other task can use for any purpose. Also, when you pass an object to the caller, the caller can ask questions about the data structure via its functions. The developer doesnt have to know what the previous function did to the data by reading up on any documentation, or having to reverse engineer the code.
    I suggest the best way of learning this is to code something like a library object.
    A library object contains a collection of book objects
    A book object contains a collection of chapter objects
    A chapter object contains a collection of paragraph objects
    A paragraph object contains a collection of sentence objects
    A sentence object contains a collection of word objects.
    Add functions to each object to provide a service
    Example: A library object should have a:
    public void addBook(Book book)
    public Book getBook(String title)
    public boolean isBookInLibrary(String title)
    The key is to add functions to provide a service to anyone who uses your object(s)
    For example, what functions (service) should a paragraph object provide?
    It shouldn't provide a function that tells how many words there are in a sentence. That function belongs to a sentence object.
    Lets say you want to add a new chapter to a book. The task is easy to read
    if you write your objects well:
    Sentence sentence1=new Sentence("It was a dark and stormy night");
    Sentence sentence2=new Sentence("Suddenly, a shot ran out");
    Paragraph paragraph=new Paragraph();
    paragraph.addSentence(sentence1);
    paragraph.addSentence(sentence2);
    Paragraphs paragraphs=new Paragraphs();
    paragraphs.addParagraph(paragraph);
    Library library= new Library();
    library.getBook("My Novel").addChapter("Chapter 1",paragraphs).
    Now, lets say you want to have a word count for the entire book.
    The book should ask each chapter how many words it contains.
    Each chapter should ask its paragraphs, each paragraph should ask
    its sentences. The total of words should ripple up and be tallied at each
    stage until it reaches the book. The book can then report the total.
    Only the sentence object actually counts words. The other objects just tallies the counts.
    Now, where would you assign a librarian? What object(s) and functions would you provide?
    If written well, the project is easily extensible.

  • Doubts in GeoRaster Concept.

    Hi everybody,
    I have few doubts in GeoRaster concepts.
    I did mosaicing of multiple Georasater objects using "sdo_geor.getRasterSubset()" and able to display image properly. But while doing this I come across few people suggestions. They said that mosaicing multiple rows together in a GeoRaster table is not going produce meaningful results because the interpolation methods wont have access to the data in the adjacent cells at the seams because cell needed exist in a different row (i.e. where two rows of GeoRaster either abut or overlap).
    I assume Oracle takes care of all this. Please suggest wheather my assumption is true or the statement given is true?
    Regards,
    Baskar
    Edited by: user_baski on May 16, 2010 10:49 PM

    Hi Jeffrey,
    Requirements:-
    I have to do mosaicing of 'n' number of Georaster objects. For eg, if table has 4 rows of GeoRaster object, then i have to create single image by mosaicing all the Georaster object based on the Envelope provided. (Note: I have to do this with Queries without using GeoRaster API)
    Workflow:-
    1. Get the connection and table details.
    2. Retrieve necessary information from the db like SRID, MAXPYRAMID, SPATIALRESOLUTION, EXTENT etc. For getting extent, I used SDO_AGGR_MBR function.
    3. With the help of "MDSYS.SDO_FILTER" and bouding box values, I create arraylist which contains raster id's retrieved from raster data table which covers the bouding box value provided in the filter command.
    4. Then I passed bounding box value into "sdo_geor.getCellCoordinate" function and I retrieved row and column number of Georaster image and created a number array which contains starting and ending row/column numbers.
    5. Then I had written a PL/SQL with "sdo_geor.getRasterSubset" function which takes the number array and raster id as input parameters, which inturn returns BLOB object.
    6. I am executing step 5 in a loop with all the raster id's that I got at step 3. For eg, arraylist size is 4, then I will have four BLOB object.
    7. Finally, I creating new image from the BLOB objects after some scaling and cropping based on the individual GeneralEnvelope of each raster id object.
    I had followed all the above steps and successfully created mosaic image.However, few people suggested that mosaicing in this way does not produce meaningful results because the interpolation methods wont have access to the data in the adjacent cells at the seams because cell needed exist in a different row. I assume Oracle will take care of these things. Moreover, they suggested to keep single row in GeoRaster table instead of muliple rows of Georaster object and suggested to use "SDO_GEOR.updateRaster" function to update a part of the raster object and the pyramids are rebuild automatically.
    So Please suggest which is the better way to do mosaicing. Wheather my assumption is correct or not?

  • Quesion about the Basic concept of RMAN incremental backup

    I have a problem in understanding the basic concept of two types RMAN Incremental backup ie. Differential and Cumulative. I just don't understand how cumulative incremental backup consumes more space than Differential backup.
    Have a look at the scenario in which Differential backup is used.
    1. On Sunday midnight, a LEVEL0 backup is taken.
    2. On Monday midnight all the blocks that was changed since Sunday midnight are stored in the backup media (tape or disk)
    3. On Tuesday midnight all the blocks that was changed since monday midnight are stored in the backup media.
    4. On Wednesday midnight, all the blocks that was changed since tuesday midnight are stored in the backup media.
    At this point, in the backup media, you have all the changed blocks from sunday midnight to wednesday midnight eventhough it was stored in a daily basis. If you had taken a cumulative backup at wednesday midnight the backup media would have contained the same changed blocks from sunday midnight(LEVEL0) to wednesday midnight, but all at one go instead of daily basis. I don't understand how cumulative backup consumes more space when the backup media contains the same amount of changed blocks as it were in the case of the Differential backup.

    Considering the Scenario you given:
    Sunday : Level 0 backup.
    Monday : You have taken an incremental backup then there will not be any difference in size of backup set for differential or cumulative as the changes from last Level0 backup are considered.
    Tuesday : A cumulative backup (n-1) will have changed blocks since Sunday's Level0 backup but a differential backup(n) will only have changed blocks since Monday. So definitely there will be more space consumed by cumulative backups compared to differentials.
    Hope it helps ...
    Bhupinder

  • Doubt in Basic ABAP.

    Hi Gurus,
    I have a small doubt in basic ABAP.
    What is the exact difference between the below statements.
    Types: Begin of ty_data,
                 matnr type mara-matnr,
              end of ty_data.
    Types: Begin of ty_data,
                 matnr type matnr,
              end of ty_data.
    Types: Begin of ty_data,
                 matnr like mara-matnr,
              end of ty_data.
    Types: Begin of ty_data,
                 matnr like matnr,
              end of ty_data.
    data: matnr type mara-matnr.
    data: matnr type matnr
    data: matnr like mara-matnr
    data: matnr like matnr.
    In those above statement which are correct. And the difference between those statements.
    Thanks,
    Srihari.

    hi,
    LIKE means the datatype of the variable is similar to the referenced variable.
    TYPE means it is a predefined data type.
    Eg:
    DATA int TYPE i.
    Here int is of integer data type.
    DATA var LIKE int.
    var IS a variable having same data type of int. which in turn is integer.
    You can find these helpful when you reference database table variables... You need not know what is the datatype defined.
    Also it adds to FLEXIBILITY.
    Whenever you make changes to your database tables and fields,
    that change is REFLECTED back to your program that is,
    You need not change all your program code when you change your table fields...
    Hope you understand and appreciate the flexibility that SAP provides to the programmers...
    Thanks
    Arun

  • Doubt in Dataguard concept

    Dear all,
    Please help me regarding this i am very much confused.....
    I had couple of doubts in dataguard concepts.
    1)When archive log is transferred from primary to standby ,
    a.Whether DBWR will be in active state or not in standby server.To write the contents in the archived redo log files which came from the primary to the datafiles of the standby server.
    b.I am using online redo logs in the standby server not standby redo logs , whether online redologs in the standby server will have any effect in shipping of redologs from the primary database,
    c. In my standby database online redo logs state is changing between CLEARING AND CLEARING CURRENT.How standby server redologs will change it state,
    Regards,
    Vamsi.

    Hi again,
    They are not used in a physical standby database. They exist in order to be used in a case of opening the standby database read-write (failover/snapshot standby). Here what documentation says:
    Online redo logs
    Every instance of an Oracle primary database and logical standby database has an associated online redo log to protect the database in case of an instance failure. Physical standby databases do not have an associated online redo log, because physical standby databases are never opened for read/write I/O; changes are not made to the database and redo data is not generated.
    Create an Online Redo Log on the Standby Database
    Although this step is optional, Oracle recommends that an online redo log be created when a standby database is created. By following this best practice, a standby database will be ready to quickly transition to the primary database role.
    ...

  • I'm missing a basic concept on iCal.

    I'm missing a basic concept on iCal Server i think.
    I just want to publish a single calendar to the public from the server, not from the local client; with NO passwords.
    Calendars exist on the iCal Server on 10.8.5 using login credentials from Open Directory where users
    can create calendars, share calendars, etc.
    When you go to the Web site, it first asks for your login and password.
    How do i link a calendar to a public location, or make a calendar publicly accessible?
    Thanks in advance
    Tim Far
    OSX Server, OS X Mountain Lion (10.8.5)

    So with no responses to the above question, I've had to rtfm...
    It appears from my reading of the somewhat limited documentation on iCal Server on 10.8.5, since I have chosen
    to apply security to the Wiki's and Calendars to use OD on the server; I cannot open a public viewable Calendar along side the secured ones.  ( I may certainly be wrong, but I haven't been able to find out how.)
    So I took an easier approach, as I wanted 1 public calendar viewable and subscribable by the public.
    The local iCal server will be used privately for local secure business, while the Public calendar will be
    maintained on the local Admin's desktop, then shared publicly to Google calendars, where I set up a simple secure acount.  This gives me 4 benefits.
    1. A public viewable webpage of the calendar - for those with iCal or iPhone (droid population, or browsers)
    2. An dot.ics subscribable link  for those with iPhones, iCal compatibe calendars
    3. An embedded link for our education web site, to show the Public calendar inline on our own website.
    4. The ability to publish to said Google calendar , from the locally managed desktop.
    This may have been obvious, or not; and potentially othe ways of accomplishing the same,
    Any thoughts or goctcha's ?
    Thanks in advance.

  • I've a doubt in basic thing.

    Hi all
    I've a doubt in basic thing.
    IActiveContext* myContext;
    InterfacePtr<ITextEditSuite> textEditSuite(myContext->GetContextSelection(), UseDefaultIID());
    textEditSuite->InsertText(WideString(rString));
    in above lines, myContext->GetContextSelection() returns ISelectionManager. Then how textEditSuite can be created. could any one please explain?
    thanks in advance
    Ays.Hakkim

    HI
    But you already creating "textEditSuite" from ISelectionManager. In That code that you pasted above.
    To get ISelectionManager you can either use IActiveContext::GetContextSelection or ISelectionUtils.
    Let's say you have a an interface pointer to ISelectionManager named mySelectionMgr;
    All you need to do is create your interface pointer to ITextEditSuite - textEditSuite:
    InterfacePtr<ITextEditSuite> textEditSuite(mySelectionMgr, UseDefaultIID());
    if (textEditSuite && textEditSuite->CanEditText())
         ErrorCode status = textEditSuite->InsertText(WideString(resultString));
         ASSERT_MSG(status == kSuccess, "WFPDialogController::ApplyFields: can't insert text");
    This is code from InDesign SDK Documentation. You can find there more examples of "How to use ITextEditSuite".
    Regards
    Bartek

  • SAP BI basic concept

    Hi all
    I am new in SAP BW and have a basic practical experience (4 months) but not very confident on basic concept of BI .Can any  tell us from where i can learn  those

    Mail me at [email protected]

  • Doubts on casting concepts in TAW12 part 1

    Can someone help me clarify a little confusion on Casting in materials provided by SAP Education on TAW12 part 1.
    I attended ILT and my instructor emphasized that: "wherever in this material we read 'Up-cast' or 'Down-cast', we should consider this as an error because what they meant to say is exactly the opposite".
    This has now left me confused especially after revising.
    Can someone please share some light on these terminologies and concept? especially in relation to materials provided on TAW12 ABAP Workbench Concept Part 1 (2013 SAP AG. All rights reserved)
    I have not been able to find much materials online for this section of the book and for many others.
    Any help would be greatly appreciated.
    Vince

    Hi Vince,
                   First thing, STOP worrying about the SAP material whether the contain is right/wrong.
                  Now, what I understand is that the instructor tried to explain the concepts in a easy way to remember but has that seems to have messed up your basics on up-cast & down-cast.
    I have looked in my sap material ( but its 2005 SAP AG reserved ).  The definition are fine.
    Anyways I'll try to explain in my style:
    Narrow casting( up-casting ):- Assigning of a subclass instance to a reference variable of type " reference to super class ". Here we navigate from a more detailed view to one with less details.
    Widening Cast( down-cast ):-  Assigning a super class to a sub class. From a less detailed view to more detailed view.
                             SUPER CLASS( vehicle ) less details
                                       |
                                       |
                                       |
                                SUB CLASS ( car, truck, bus, bike ) more details
    PS:- Try to understand the meaning from the example and then go back to the definition in the material.

  • Doubt in some Concepts

    Hi everyone,
    I have doubts with some security concepts, i've been reading documents, but i can clear this things up.... here's the thing....
    What exactly are a keystore, certificate and .pfx or p12 files?
    i understood that a pfx or p12 files are keystores whose have inside public and private keys.... but in my concept a certificate also have a public key and a private key..so i can say that keystores are certificates.... but i'm messing this concepts up, pretty sure of that....
    Could anyone help me?
    Thanks in Advance
    Edited by: cs.santos on Jun 16, 2009 12:28 PM

    1. Certificates only have public keys in them
    2. PFX and PKCS12 are essentially the same thing.
    3. PKCS12 is a format that is typically used to store a single keypair, both the public and private parts.
    4. KeyStore is a java class the provides storage for keys of all kinds, as the name implies. The KeyStore class supports different formats; one of these is PKCS12

  • Doubt in Basic Bapi function

    Hi experts,
    I have a small doubt in BAPI, Actually i want to add the vendor price only in MEK1. For that am using BAPI to add the vendor price.
    Can anyone tell where we need to write the source code? We need to write a report program? How it will trigger the particular transaction?
    Can any one explain this?
    Mohana

    Hi Mohana,
    for that you need to seacrh for the BADI or Userexit,...when ever any changes are maded in that transaction based one the situation your BADI or userexit will trigger and that will update to the data base...if you use that BAPI in that EXIT.....
    if you are using separatly the program...every time you need to execute that program for updating that field in that transaction...
    Thanks!

  • How ODI works? Doubt in basic Architecture.

    Hi,
    I need to know how ODI (Architecture) works on basic transformations. From my understanding,
    1) ODI extracts the data from source, create some temp tables in Staging Area and put the data in temp table.
    2) From that temp table it puts the data to target and drop the temp table.
    is the two statements are correct? one more thing is that i am confident on 3rd point, please say wether its right.
    3) We can make all the temp tables to be created in a different database without affecting the target database (Using the option"Staging area diff from target")
    Any suggestions would really help.
    Thanks in Advance,
    Ram Mohan T

    Hi,
    Thanks a lot for your reply. I need no temporary tables should be created in target database. For that, i have taken
    Source and target from different databases and staging area as different database (in total three database for source, target and staging area).
    I used these knowledge modules - LKM Sql to Sql, IKM Oracle Incremental update, CKM oracle.
    When i execute the interface, two tables are created in target database (SNP_Check_tab, E$_emp_table), how can i avoid that.
    Any suggestions would really help.
    Thanks in Advance,
    Ram Mohan T.

  • Doubt in basic stuff

    Hi all,
    I have installed 10g app server and also new to 10g.
    My doubt is , is there any way to created domain in 10g app server as in weblogic .
    Please reply to this.
    Srini

    Hi all,
    I have installed 10g app server and also new to 10g.
    My doubt is , is there any way to created domain in 10g app server as in weblogic .
    Please reply to this.
    Srini

  • Doubt in Overloading Concept in Packages

    Hi,
    I have two Stored Procedures are inside a package
    sp_mem(mCursor REFCURSOR Datatype,MemberId INTEGER);
    sp_mem(mCursor REFCURSOR Datatype, mEmailId INTEGER);
    In the Above Procedures if the second Parameter is Member Id then the first SP will be executed.
    In the Above Procedures if the Second Parameter is MemEmailId then the Second SP will be Executed.
    This is the normal OverLoading Concept inside the package. But for me, i am returning the Recordset using a RefCursor.
    I just want to know it is possible for returning the recordset using ref cursor with the overloading concept for both the SP.
    Thanks,
    Murali.V

    Hello
    You need to be careful with this type of overloading. Overloading is generally based around the position and data types of the parameters being supplied which are used to identify the "signature" of the particular procedure to call i.e.
    sp_myproc(ref cursor, integer)
    sp_myproc(ref cursor, date)
    sp_myproc(ref cursor, varchar2)
    sp_myproc(ref cursor, varchar2, integer)
    etc etc
    When you have 2 procedures that have the same signature, unless you specify the name of the parameter, there is no way to determine which procedure to call:
    tylerd@DEV2> CREATE OR REPLACE PACKAGE pkg_test_overload
      2  IS
      3
      4     PROCEDURE sp_mem(mCursor sys_refcursor,MemberId INTEGER);
      5     PROCEDURE sp_mem(mCursor sys_refcursor, mEmailId INTEGER);
      6
      7  END;
      8  /
    Package created.
    tylerd@DEV2>
    tylerd@DEV2> CREATE OR REPLACE PACKAGE BODY pkg_test_overload
      2  IS
      3
      4     PROCEDURE sp_mem(mCursor sys_refcursor,MemberId INTEGER)
      5     IS
      6
      7     BEGIN
      8
      9             NULL;
    10
    11     END;
    12
    13     PROCEDURE sp_mem(mCursor sys_refcursor, mEmailId INTEGER)
    14     IS
    15
    16     BEGIN
    17
    18             NULL;
    19
    20     END;
    21
    22  END;
    23  /
    Package body created.
    Package body created.
    tylerd@DEV2> var mycursor refcursor
    tylerd@DEV2> var memberid number
    tylerd@DEV2> exec pkg_test_overload.sp_mem(:mycursor,:memberid)
    BEGIN pkg_test_overload.sp_mem(:mycursor,:memberid); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00307: too many declarations of 'SP_MEM' match this call
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    tylerd@DEV2> exec pkg_test_overload.sp_mem(:mycursor,MemberId=>:memberid)
    PL/SQL procedure successfully completed.
    tylerd@DEV2> exec pkg_test_overload.sp_mem(:mycursor,mEmailId=>:memberid)
    PL/SQL procedure successfully completed.To me, using named notation with overloading kind of defeats part of the objective...I'm not saying it's completely wrong, as sometimes I guess it's unavoidable, but I'd review the design carefully :-)
    HTH
    David
    Message was edited by:
    David Tyler
    Oops, copied the wrong bit of the output! :-)

Maybe you are looking for

  • CST changed from 3% to 2 %

    Dear all Now this fiscal year CST changed from 3% to 2% we are maintaining the taxcode as I3 with 3% and condition type JIP4--A/P CST Non deductib in TAXINJ-India tax Procedure. now we want change the tax % from 3 to 2 how can i proceed wht are the P

  • I canu00B4t modifyRowInDB, but not appear error...

    Hi, i have a problem... i´m doing a SmartSync Project, and i want modify a row with the method modifyRowInDB. My steps are:      public void modificarIMP (String BO, String m, Vector lista) {           for (int i = 0; i < lista.size(); i++) {        

  • Unable to Run Real Time Job Idoc Processing.

    hi experts, i am trying to run a job in which i m trying to process a SAP IDOC. my source is an MATMAS03 type IDOC MESSAGE. I m running it through Management Console. the RFC is working fine, but when the idoc is getting processed, at the end i m get

  • Windows Retina Support

    When is Photoshop CS6 going to support retina (or any hidpi) on Windows? I am using a macbook pro retina with bootcamp.

  • Run SQL from UNIX

    How could I run sqlplus from an Unix machine?