1 / 7

600.226 Java intro

600.226 Java intro. Subodh Kumar Johns Hopkins University. Java: A high level objected oriented programming language. Object Oriented language; like C++ Class, Object, method No */& address ops No free/delete/malloc Architecture independent In-built: Graphics networking

malo
Download Presentation

600.226 Java intro

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 600.226 Java intro Subodh Kumar Johns Hopkins University

  2. Java: A high level objected oriented programming language • Object Oriented language; like C++ • Class, Object, method • No */& address ops • No free/delete/malloc • Architecture independent • In-built: • Graphics • networking • thread management • memory management • Error Handling

  3. Declaring Classes public class Gnome { // body } Extended/instantiated within package / by importer otherwise only within the package abstract class Gnome { } Only abstract methods final class Gnome { } No subclasses allowed

  4. Deriving sub-classes class Gnome extends Dreblin { // body } Redefine/Add to variables/methods. class Gnome implements Dreblin, Timken { // body } Define methods of an interface

  5. Local variables class Gnome { // InstanceVariables public Tot[] tots; // class Tot is visible here. // tot1 is exported with Gnome protected String name; // Visible to package and // sub-classes private int age; // Visible Only within the class static final int NTOT = 2; // Visible within package // Value can’t be changed // Methods }

  6. Methods abstract class Gnome { // Instance Variables // Methods public abstract void hiFunda(int party); final int getAge() { return age; } // May be public, protected, private // static, final, and abstract (if the class is abstract) }

  7. Instance initialization: Constructors class Gnome { // Constructor Method public Gnome (String x) { name = x; tots = new Tots[NTOT]; } // May be public, protected, private // static, final, abstract not allowed } Usage: Gnome gnome1 = new Gnome(”Baital”)

More Related