0% found this document useful (0 votes)
54 views8 pages

JAVA Notes

The document discusses several Java concepts including built-in packages, features of Java, inheritance types, arrays, access specifiers, File class methods, streams, logical operators, command line arguments, platform independence, constructor types, differences between arrays and vectors, interfaces, compile errors, applet lifecycle, and thread lifecycle.

Uploaded by

cohoti1106
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
54 views8 pages

JAVA Notes

The document discusses several Java concepts including built-in packages, features of Java, inheritance types, arrays, access specifiers, File class methods, streams, logical operators, command line arguments, platform independence, constructor types, differences between arrays and vectors, interfaces, compile errors, applet lifecycle, and thread lifecycle.

Uploaded by

cohoti1106
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 8

1) Built-in Packages in Java / Java API packages

 java.awt
 java.io
 java.net
 java.sql
 java.lang
 java.util

2) Festures of JAVA [“IPPPRSSD”]

 Inheritance
 Protected
 Polymorphism
 Platform Independence
 Robust
 Secure
 Supports Multithreading
 Dynamic

3) Type of inheritance

 Single level inheritance


 Multi level inheritance
 Multiple inheritance
 Hybrid inheritance
 Hierarchical inheritance

4) Define array. List its types.


An array is a homogeneous data type where it can hold only objects of one data type.
Types of Array:
One-Dimensional
Two-Dimensional

5) List access specifiers in Java.


 public
 private
 friendly
 protected
 Private Protected

1) Explain any two methods of File Class


 delete() -Deletes a file
 mkdir() - Creates a directory
 canRead() - Tests whether the file is readable or not
 canWrite() - Tests whether the file is writable or not
 Define stream class. List its types.
A stream is a sequence of objects that supports various methods which can be pipelined to produce the
desired result.
Types
Byte Streams − These handle data in bytes (8 bits) i.e., the byte stream classes read/write data of 8 bits.
Using these you can store characters, videos, audios, images etc.

Character Streams − These handle data in 16 bit Unicode. Using these you can read and write text data
only.

 Logical Operators in Java

Logical operators can be defined as a type of operators that help us to combine multiple conditional
statements. There are three types of logical operators in Java: AND, OR and NOT operators.

AND operator returns true when both conditions under evaluation are true, otherwise it returns false.

OR operator returns true if any one of the given conditions is true. OR operator returns false if and only
both conditions under evaluation are false.

NOT operator accepts a single value as an input and returns the inverse of the same. This is a unary
operator unlike the AND and OR operators.

 Explain the command line arguments


The argument thet is passed through our java program through command is called command line
arguments.
The java command-line argument is an argument i.e. passed at the time of running the java program.
The arguments passed from the console can be received in the java program and it can be used as an input.
So, it provides a convenient way to check the behavior of the program for the different values. You can
pass N (1,2,3 and so on) numbers of arguments from the command prompt.

Example-
class CommandLineExample
{
public static void main(String args[])
{
System.out.println("Your first argument is: "+args[0]);
}
}
 Explain the concept of platform independence and portability with respect to Java language.

Java is a platform independent language. This is possible because when a java program is compiled, an
intermediate code called the byte code is obtained rather than the machine code. Byte code is a highly
optimized set of instructions designed to be executed by the JVM which is the interpreter for the byte
code. Byte code is not a machine specific code. Byte code is a universal code and can be moved
anywhere to any platform. Therefore java is portable, as it can be carried to any platform.

 Explain the types of constructors

A constructor in Java is a special method that is used to initialize objects. The constructor is called when
an object of a class is created

The types of constructors are:


1. Default constructor
2. Constructor with no arguments
3. Parameterized constructor
4. Copy constructor

 Default constructor: Java automatically creates default constructor if there is no default or


parameterized constructor written by user. Default constructor in Java initializes member data
variable to default values (numeric values are initialized as 0, Boolean is initialized as false and
references are initialized as null).

 Parametrized constructor: Such constructor consists of parameters. Such constructors can be


used to create different objects with datamembers having different values.

 Constructor with no arguments: Such constructors does not have any parameters. All the objects
created using this type of constructors has the same values for its datamembers.
Array Vector
Array is unsynchronized. Vector is synchronized.
Array is not a class. Array is a class.
An array is the static memory allocation. Vector is the dynamic memory allocation.
Wrapper classes are not use in array. Wrapper classes are used in array.
An array is a homogeneous. An array is a hetrogeneous.

 Interface in Java
An interface in Java is a blueprint of a class. It has static constants and abstract methods.

 Java compile errors


 Java source file name mismatch
 Mismatched brackets
 Method is undefined
 Missing semicolons

 Life Cycle of Applet


An applet is a java program that runs in a web browser.(java enable web browser)
An applet is a java class that extends the java.applet.applet class.
An applet does have main() method.
1) init()
2) start()
3) paint()
4) stop()
5) destroy()
init()-Every Applet will start it’s execution from init() method. It is executed only once

start()-After init() method start() method is invoked. Executed when the browser is maximized

paint() - Paint method is used to display the content on the applet. We can create the objects or
components to the applet or we can directly write a message on the applet. It will take Graphics
class as a parameter.

stop() - stop() method is used to stop the applet. It is executed when the browser is minimized.

destroy() - destroy() method is used to completely close the applet. It is executed when the
applet is closed.

 Life Cycle of Thread


1) Newborn
2) Runnable
3) Running
4) Blocked (Non-Runnable)
5) Dead (Terminated)
Newborn State - When a thread object is created, the thread is said to be in born state. At this moment,
the thread is not scheduled for running

Runnable State - The runnable state means that the thread is ready for execution and is waiting for the
availability of the processor. In simple terms, the thread is ready but has not got the processor time.

Running State - When the thread starts executing, then the state is changed to a “running” state. The
scheduler selects one thread from the thread pool, and it starts executing in the application.

Blocked State - A thread is said to be blocked when it is prevented from entering into the runnable
state and subsequently the running state. This happens when the thread is suspended, sleeping, or
waiting in order to satisfy certain requirements.

Dead State - A thread is said to be in dead state when it has been killed by using kill() method or it has
successfully completed its execution.

You might also like