Java-Part 5

Java 2-Part 4   Index   Java 2- Part 6
*We can develop few of the following types of java programs

  • Standalone java programs
  • Web Applets etc.,

*Applets included in the web document (html) & run inside the web page. Every Applet has its own area of the screen known as “Canvas”

*Standalone programs read & write files and perform certain operations that applet can’t do.

*Structure of Java Program

  • Documentation section
  • Package Statement
  • Import Statement
  • Interface Satement
  • Class definitions
  • main method

*main method is used to establish communication between different classes.

*Smallest individual unit is called token

  • Reserved words
  • Identifiers[var]
  • Literals
  • Operators
  • Separators

*The characters are used in Java is Unicode characters which uses 16bit[34000 characters defined]. ASCII is subset of Unicode. Around 24 languages are covered in Unicode.

*All keywords of Java are written in lower case.

*Identifiers are program defined tokens.

*Java supports 5 major types of literals.

  • int
  • float
  • char
  • String (is literal, but an object)
  • boolean

*A Statement is a executable combination of token ending with a semicolon(;).

JavaStms

*Java file name contains class name property.

*JVM is in the memory.

*Command line args are passed to the program at the time of invoking the program.

*Synchronization is the process of making the queue mechanism on Threads.

*We can’t declare abstract constructors and abstract static methods.

*Dynamic method dispatch is the mechanism by which call to the overridden method can be resolved at run time rather than at compile time.

*ResourceBundle Types

  1. ResourceBundle
  2. ListResourceBundle
  3. PropertyResourceBundle

*PropertyPermission is a permission which allows you grant a read & write permission to the System property.

*Java Collection framework standardizes the way in which groups of objects are organized.

*ArrayList is variable length array of object references.

*Serialization is the process of writing the state of an object to a bytestream

*A Socket is used to connect I/O System to the other programs.

*An event represents an action occurred, it contains the information about the event, time & location.

*There can be only one public interface declared in a single compilation unit.

*The only argument a case evaluate is one of the same type as switch can use with one additional & big constraint, the case argument must be final.

*System.exit(), all program execution stops, the JVM shutdown.

*Methods can be overloaded & overridden but the constructors can only be overloaded.

*Overriding lets you redefine a method in a sub class, when you need sub-class specific behavior.

*The overriding method can’t have more restricted access modifier than the method being overridden.

override

*Every class including abstract class must have a constructor.

*Constructors are never inherited, they aren’t methods, they can’t be overridden.

*The benefit of having overloaded is that, your offer flexible ways to instantiate objects from your class.

*To overload a method, you must change the argument list.

*Overloaded methods can change the return type, but overriding methods can’t(till 1.5).

*You can return null in a method, that has an object reference as a return type.

* To make java more memory efficient the JVM sets aside a special area of memory called “String constant pool”.

*When the compiler encounters a string literal, it checks the pool to see if an identical string already exists.

*StringBuffer methods operate on the value of the StringBuffer object invoking the method.

*We can’t use “equals()” method on primitive types.

*An object is eligible for garbage collection, when no live thread can access it.

*Within an innerclass code, the “this” reference refers to the instance of the inner class.

*The only modifier you can apply to the method local inner class are abstract & final.

*One thing keep in mind about anonymous interface implementors,  they can only implement one interface.

*Once the thread is dead, it can never be restarted.

*All of the StringBuffer methods operate on the value of the StringBuffer object invoking it.

*Whenever we get the exception, an object representing that exception will be created & will be thrown and that will be caught in catch block.

*Whenever we pass an object to System.out.print(), it returns the ASCII value prefixed with the class name, if we aren’t provided the constructor for the object that we passed.

*Whenever we start the thread using start() method JVM add that one to the thread queue & will execute run() method in a separate process.

*Hashtable only stores objects that override hashcode() & equals() method of object class.

*One useful capability of the “Properties” class, that you can specify a default property that will be returned if no value is associated with a certain key.

*A java exception is an object that describes an exception condition, that has occurred in the piece of code.

*Exceptions are caused by Java runtime system or they can be manually generated.

*All Exceptions types are sub classes of the built in class “Throwable”. Its having 2 sub classes.

  1. Exception ->RuntimeException
  2. Error

*When you use multiple catch statements it is important to remember that exception subclass must come before any of their super classes.

*Simple types int/char as well as non-throwable classes such as “String” and “Object” can’t be used as Exceptions.

*All java built in rutime exceptions have atleast 2 constructors

  1. with no parameters
  2. with String parameters.

*Chained exception feature allows to associate other exception with an exception. The second exception describes the cause of first exception.

*ChainedException methods

  1. getCause()=>returns exceptions that underlies the current exception
  2. getInitCause()=>invoking exception returns exception.

* You can call initCause(), only once for each exception object.

*We can’t use “Error” & “RuntimeException” classes & the sub classes of above can’t be used along with the “throws” statement.

*New I/O => The new I/O system is built on 2 fundamental items.

  1. Buffers    ==>Holds the data.
  2. Channels ==> an open connection to an I/O device as file/socket.

*MappedByteBuffer” is a sub class of “ByteBuffer” that is used to map a file to buffer.

*A specific type of channel returned depends upon the type of object “getChannel()” is called on.

*You can encode a sequence of character to bytes using “encoder”.

*You can decode a sequence bytes into characters by using a “decoder”.

*Selector supports key- based non blocking multiplxed I/O, in other words selectors enable you to perform I/O through multiple channels. Selectors are most applicable to Socket-based channels.

Java 2-Part 4   Index   Java 2- Part 6

2 thoughts on “Java-Part 5

Leave a comment