4. Java ABC
Imran Daud
FURC
High Level language
What are Java Packages?
How we use Packages?
How do we write Java Program?
How to compile Java program?
what is .class file?
How to run Java program?
Java as OOP
Java Documentation
5. High level language
Imran Daud
FUIMCS
Closer to human languages
They are easier to read, write, and maintain
Platform independent.
6. Packages?
Imran Daud
FUIMCS
organizing Java classes into namespaces similar to
the modules.
Packages stored into JAR files to allow classes to
download faster in group rather then one at a time
Package contains:
Classes
Interfaces
7. How to use Java Packages?
Imran Daud
FUIMCS
import java.awt.event.*;
Keyword: import
Hierarchy of classes.
Each packages contain different set of classes
Each class can use protected data member and data
functions directly of other classes within same
package.
8. How to Write java program
Imran Daud
FUIMCS
Case Sensitive.
Class based coding.
Has ‘main’ function.
class name and file name should be same.
Objects instantiated in main using new keyword.
Save file with extension ‘.java’
Example:
9. Compiling java code in Dos mode
Imran Daud
FUIMCS
‘Bin’ folder Path to be defined.
Use ‘javac’ command to complie.
javac File_name.java
After compiling ‘File_name.class’ is generated.
10. What is .class file
Imran Daud
FUIMCS
Bytecode
If a file contains more then one classes then a
separate .class file will be generated for each class.
‘.class’ file can be run with JVM.
11. How to run java program (Dos shell)
Imran Daud
FUIMCS
Use ‘java’ command to run .class file.
Example:
Java File_name
12. Java as OOP
Imran Daud
FUIMCS
Java is based on OOP concepts.
Main feature of OOP is inheritance.
We inherit classes using ‘extend’ keyword.
Public Class My_prog extends InheritedFile
{
}
we make objects to access data members or data
functions.
13. Class VS Interface
‘extend’ Class whereas ‘implement’ interface
Class can have instance but interface don’t
Re-declare ALL functions in interface.