A special member which initializes an object immediately upon creation. It has the same name as the class name in which it resides and is syntactically similar to any method.
Types of constructors
Default constructor
Parameterized constructor
Copy constructor
Class
A user defined data type which groups data members and its associated functions together
Object
A basic unit of Object Oriented Programming and represents the real life entities
Methods of FileInputStream Class
void close()
int read()
int read(byte[] b)
read(byte[] b, int off, int len)
int available()
Error
Mistakes that can make a program go wrong. They may be logical or typing mistakes, and can produce incorrect output, terminate execution abruptly, or cause the system to crash.
Types of errors
Compile time errors
Runtime errors
Java API packages
java.lang
java.util
java.io
java.awt
java.net
java.applet
Array
A homogeneous data type where it can hold only objects of one data type
Types of arrays
One-Dimensional
Two-Dimensional
Access specifiers in Java
public
private
friendly
protected
Private Protected
String
A major class where length is fixed (immutable) and contents cannot be modified
StringBuffer
A peer class of String where length is flexible (mutable) and contents can be modified
Defining a class Circle
1. Initialize data members pi and radius
2. Display values of data members
3. Calculate and display area of circle
Exception
A problem that arises during the execution of a program. Java exception handling is used to handle error conditions systematically.
Built-in exceptions
Arithmetic exception
ArrayIndexOutOfBounds Exception
ClassNotFoundException
FileNotFoundException
IO Exception
NullPointerException
NumberFormatException
StringIndexOutOfBoundsException
OutOfMemoryException
SecurityException
StackOverflowException
drawRect()
Displays an outlined rectangle. Syntax: void drawRect(int top,int left, int width,int height)
drawOval()
Draws an ellipse or circle. Syntax: void drawOval(int top, int left, int width, int height)
Byte stream class
Designed for byte streams. InputStream and OutputStream are abstract classes that define Java's model of streaming byte input and output.
Character stream class
Designed for character streams. Reader and Writer are abstract classes that define streaming character input and output.
Applet life cycle
1. init()
2. start()
3. paint()
4. stop()
5. destroy()
Class
Doesn't support multiple inheritance, uses "extend" keyword to inherit, contains method body