• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help With Classes Needed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently in my Java class we are working with semi-advanced types of classes, of which I can't seem to understand. I was wondering if someone could point out to me a resource for the following items, preferably with analogy-like explanations. Any help that can be provided that doesn't include references, is welcome too.
  • abstract class
  • abstract method
  • class (static) method
  • class (static) variable
  • concrete classes
  • final method
  • inheritance
  • interface
  • overriding
  • postcondition
  • precondition

  •  
    Ranch Hand
    Posts: 75
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I think you should try Thinking in Java by Bruce Eckel
    Bruce Eckel
    It has detailed explanation on all the topics(BTW the book is available for free download )
     
    Sheriff
    Posts: 7023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    First of all, here is a list of free on-line Java tutorials and books that I have found useful:
  • Sun's Java Tutorial
  • Introduction to Computer Science using Java by Bradley Kjell
  • Introduction to Programming Using Java by David J. Eck
  • Dick Baldwin's Java Programming Tutorials
  • Interactive Programming In Java by Lynn Andrea Stein
  • Bruce Eckel's Thinking In Java
  • JavaRanch's own Campfire Stories
  • Allen B. Downey's How To Think Like A Computer Scientist

  • Now, some quick examples of your topics.
    abstract class - a class declared to be abstract
    Note that such a class cannot be direction instantiated with the new operator.

    abstract method - a method without an implementation
    Such a method can only be declared in an abstract class or in an interface. Non-abstract subclasses or classes that implement the interface must provide an implementation of the declared abstract method.

    Note that the method in the interface did not need to be labeled abstract. All methods declared in an interface are implicitly abstract.
    Also note that all methods declared in an interface are implicitly public, even if not explicitly declared to be so. As such, the implementing class must also declare the method to be public.
    class (static) method - a method in a class defined to belong to the class, and not to instances of the class

    Note that it wasn't necessary to create an instance of Foo in order to call the static method.
    class (static) variable - much like a static method, this is a variable defined in a class to belong to the class, not to instances of the class

    Note that it wasn't necessary to create an instance of the Foo class in order to access and use the static variable i.
    concrete classes - A class that is not abstract.

    final method - such a method cannot be overridden in a subclass

    inheritance - a mechanism whereby one class definition can extend another, where the extending (sub)class inherits some (or all) of the behaviors (methods) defined in the extended (base) class
    This is a fundamental concept of object-oriented programming.

    Note that even though the Foo class does not define a method named method, the foo instance has access to the one defined in the parent class Bar.
    interface - a mechanism for categorizing/marking implementing classes with another data type
    Note that since only single inheritance is allowed in Java (that means a class can be defined to extend at most one other class), this implementing of interfaces is especially useful for developing well designed, polymorphic code.
    Above is an example using an interface. For a greater understanding of the role of interfaces and just what polymorphism is, spend a few minutes reading the "How my Dog learned Polymorphism" story of the JavaRanch Campfire Stories.
    overriding - where a subclass declares a (non-static, non-private) method with the same signature as one in a parent class.

    postcondition - something concerning the state of a system (or object) that may have changed after a method is invoked
    In other words, something that is true after a method is called - something concerning an object's state, that is.
    precondition - something that must be true before a method is called
    This might be something about the state/value of a method parameter, or something about the state of the object that has the method being called.
    Making any sense?
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic