Skip to main content

Posts

JAVA : W1-M3

Inheritance Learning Objective Welcome to the Day2 in Java . Here we would concentrate on solving Inheritance Problems. Inheritance Member Access & Inheritance Using Super Method Overriding Dynamic Method Dispatch Inner Classes Orientation Video Introduction Inheritance: Inheritance is the capability of a class to use the properties and methods of another class while adding its own functionality. In Java, inheritance is used for two purposes: 1. Class inheritance - create a new class as an extension of another class, primarily for the purpose of code reuse. That is, the derived class inherits the public methods and public data of the base class. Java only allows a class to have one immediate base class, i.e., single class inheritance. 2. Interface inheritance - create a new class to implement the methods defined as part of an interface for the purpose of subtyping. That is a class that implements an interface “conforms to” (or is constrained b...

JAVA : W1-M4

Interface Learning Objective Welcome Back!. In this Module let us solve Problems related to Interface . Defining an Interface Implementing Interfaces Applying Interfaces Variables in Interfaces Interfaces can be extended Orientation Video Introduction Interface: In the Java programming language, an interface is a reference type, similar to a class, that can contain only constants, method signatures, and nested types. There are no method bodies. Interfaces cannot be instantiated—they can only be implemented by classes or extended by other interfaces. Extension is discussed later in this lesson. Defining an interface: Interfaces are defined with the following syntax (compare to Java's class definition). [ visibility ] interface InterfaceName [ extends other interfaces ] { constant declarations member type declarations abstract method declarations } The body of the interface contains abstract methods, but since all met...

JAVA : W1-M5

Packages Learning Objective * Package Concepts in Java Orientation Video Introduction Packages: Multiple classes of larger programs are usually grouped together into a package. Packages correspond to directories in the file system, and may be nested just as directories are nested. Package = directory. Reasons to use packages • Grouping related classes. • To allow classes to be combined in a single ".jar" file. • To control the namespace. • To limit the scope of names. Grouping related classes. If you are writing a normal one-programmer application, it will typically be in one package. The purpose of a package is to group all related classes together. If you are working on a program that is divided into separate sections that are worked on by others, each section might be in its own package. This prevents class name conflicts and reduces coupling by allowing package scope to be used effectively. Package declarations: Each file may have a ...

JAVA : W1-M6

Exception Handling Learning Objective Welcome Back!. In this Module let us solve Problems related to Exception Handling in java . Orientation Video Introduction Exception, that means exceptional errors. Actually exceptions are used for handling errors in programs that occurs during the program execution. During the program execution if any error occurs and you want to print your own message or the system message about the error then you write the part of the program which generate the error in the try{} block and catch the errors using catch() block. Exception turns the direction of normal flow of the program control and send to the related catch() block. Error that occurs during the program execution generate a specific object which has the information about the errors occurred in the program. In the following example code you will see that how the exception handling can be done in java program. This example reads two integer numbers for the variables a and b. I...