Sei sulla pagina 1di 3

* applet is a special type of web based application.

(they r transmitted as
bytecodes).

* servlet is a special type of java application that that runs on the server and
can be called by a client usually a web browser.in servlet the code for the
application runs inside server.no special plugins are required for the browser.

* command path is set to specify where to look for java commands.


* class path is set to specify where to look for the java files that you create.

* 2 types of errors are compile time errors and runtime errors.

* an identifier can begin with uppercase or lowercase letter or underscore or $


sign.

* public static void main()//public means the main method can be accessed by other
classes.static keyword means that other classes can access the main method
directly without using an object.void means that the method doesnt return any
values.

* string can contain letters,digitsand special characters like *,# and &.

* in api for j2se,groups of related classes are organised into packages.

* java.lang package is automatically made available to all java pgms.

* awt(abstract window toolkit.) java.awt package. swing - javax.swing package

* we can also access a class without using an import stmt.eg :


java.util.scanner=new java.util.scanner(system.in);

* system.in represents console input.system.out represents console output.

* scanner sc=new scanner(system.in); string str=sc.next(); int a=sc.nextint();


double d=sc.nextdouble();//scanner class is in java.util package.

* string choice=sc.next(); if(choice.equals("y") {....}


if(choice.equalsignorecase("y"){...}

* static methods can be accessed using classname and not objects.

* java uses 2 byte unicode character set.

* by default java applications use a single thread,called main thread.

* thread is a single sequential flow of control within a program.jvm has a thread


scheduler.

* final int days_in_november=30;// its value cant be changed.

* all the threads in java including the ones thats running and others that are
eligible to be running,are in "runnable" state.

* start method changes the state of the thread from new to runnable.

* the 5 states of the thread are new,runnable.waiting,blocked,terminated.

* for creating a new thread,do 1)create a class that extends the class thread.
2)overload the method run() to perform the desired task. 3)create a thread by
instantiating an object from the class. 4)call the start method of the thread
object.

* yield() is a static method that causes currently executing thread to pause so


that other threads can run.

* threads can be created in 2 ways,by inheriting thread class and implementing


runnable interface.

* sleep() is a static function of thread class that is used to move the thread to
blocked state for a specified number of milliseconds.eg:thread.sleep(500);

* when a thread is created, its given a priority value between 1 and 10.where 10
is the highest priority and 1 lowest.

* count1.setpriority(thread.min_priorty);// to set priority. value of min_priority


is 1 max_priority is 10 and norm_priority is 5.

* by default every thread is given the priority of the thread that created it.a
thread create from main thread is given priority 5.

* a thread can be interrupted by using interrupt() method.for eg:


count1.interrupt();

* synchronised keyword assures that only one thread at a time is allowed to


execute any synchronised method of an object by locking the object.
eg: public synchronised int calculate(int a,int b) { }

* wait() palces the current thread in waiting state until another thread calls the
notify or notifyall method to current object.it releases lock on current object so
that other threads can execute synchronised methods.

* notifyall method wakesup all of the threads that are waiting for currnt object's
lock.

* i/o in java is built on streams. input streams read data. output streams write
data.filter streams can be chained to either an input stream or an output stream.
filters can modify the data as it's read or written—for instance, by encrypting or
compressing it—or they can simply provide additional methods for converting the
data that's read or written into other formats.

* java's basic output class is java.io.outputstream .the flush( ) method rescues


you from deadlock by forcing the buffered stream to send its data even if the
buffer isn't yet full.

* java's basic input class is java.io.inputstream

* the println( ) methods do the same thing, but they also append a platform-
dependent line separator character to the end of the line they write. this is a
linefeed (\n) on unix, a carriage return (\r) on the mac, and a carriage
return/linefeed pair (\r\n) on windows.

* inetaddress class represents an internet protocol (ip)


address.unicast - an identifier for a single interface. a packet sent to a unicast
address is delivered to the interface identified by that address. multicast -
an identifier for a set of interfaces (typically belonging to different nodes). a
packet sent to a multicast address is delivered to all interfaces identified by
that address.

* host name-to-ip address resolution is accomplished through the use of a


combination of local machine configuration information and network naming services
such as the domain name system (dns) and network information service(nis). the
particular naming services(s) being used is by default the local machine
configured one. for any host name, its corresponding ip address is returned.

reverse name resolution means that for any ip address, the host associated with
the ip address is returned.

* a socket is a connection between two hosts. it can perform seven basic


operations:
• connect to a remote machine
• send data
• receive data
• close a connection
• bind to a port
• listen for incoming data
• accept connections from remote machines on the bound port java's socket
class, which is used by both clients and servers, has methods that
correspond to the first four of these operations. the last three operations are
needed only by servers, which wait for clients to connect to them. they are
implemented by the serversocket class.

* the java.net.socket class is java's fundamental class for performing client-side


tcp operations.
methods like getinetaddress(),getport(),getlocaladdress(),getlocalport(). are
used to get ip nd port of remote host and local machine.
sockets provide full duplex data transfer. getinputstream() and getoutputstream()
shutdownoutput() r also othe methods.

* java provides a serversocket class to allow programmers to write servers.

* closing a serversocket frees a port on the local host, allowing another server
to bind to the port; closing a socket breaks the connection between the local and
the remote hosts.

* in java, a udp datagram is represented by an instance of the datagrampacket


class:

* a class can implement more than one interface.by contrast, a class can only
inherit a single superclass (abstract or otherwise).

* jpcapcaptor-this class is used to capture packets or read packets from a


captured file.

* networkinterface class is used to represent a network interface. it has got


fields like name,description,datalink_name,datalink_description

* networkinterfaceaddress - this class represents a network address assigned to a


network interface.

* jpcapcaptor captor=jpcapcaptor.opendevice(devices[1], 65535,false, 20);


captor.setfilter("ip and tcp", true); // setfilter method is same as tcpdump.

Potrebbero piacerti anche