+ Reply to Thread
Results 1 to 8 of 8

Thread: java notes

  1. #1
    Member
    Join Date
    Feb 2006
    Location
    Posts
    42
    Rep Power
    8
    Packages
    A package is a grouping of classes that share a common purpose or category. One member of a package has special privileges to access data and methods in other members of the package, hence the protected access modifier.A package is the Java equivalent of a library. It is a collection of classes which can be made available using the import statement. The following Java statement imports the utility library from the Java API:
    import java.util.*
    Packages are typically held in JAR files, which have the extension .jar or .zip.
    Public versus private
    An access modifier determines the visibility (essentially the public, private, or protected keyword used in front of any declaration) of a field, method or class to other Java objects.
    •A public class, method, or field is visible everywhere.
    •A private class, method, or field is visible only in methods defined within that class.
    •A protected method or field is visible to methods defined within that class, within sublclasses of the class, or within other classes in the same package.
    •The default visibility, known as package, means that the method or field is visible within the class and to other classes in the same package.
    Constructors
    A constructor is a special method of a Java class that is called when an instance of the class is created.
    Classes can define their own constructors, including multiple, overriding constructors. Which arguments were used in the attempt to create the object determine which constructor is used. When the type, number, and order of arguments used to create an instance of the class match one of the class's constructors, that constructor is used when creating the object.
    Garbage collection
    Garbage collection automatically removes any object with no references to it, with the exception of objects stored as values in a table.
    There is no such thing as a destructor method in Java (as there is in C++). Java classes can define their own finalize method for clean up operations when an object is discarded during garbage collection.
    Interfaces
    Java classes can inherit only from one class. Java uses interfaces instead of multiple-inheritance. A class can implement multiple interfaces. Each interface defines a set of methods and method profiles that must be implemented by the class for the class to be compiled.
    An interface defines what methods and static fields the class must declare. The implementation of the methods and fields declared in an interface is located within the class that uses the interface: the interface defines what the class must declare; it is up to the class to determine how it is implemented.
    Java error handling
    Java error handling code is separate from the code for normal processing.
    Errors generate an exception object representing the error. This is called throwing an exception. A thrown exception terminates a Java program unless it is caught and handled properly at some level of the application.
    Both Java API classes and custom-created classes can throw exceptions. In fact, users can create their own exception classes which throw their own custom-created classes.
    If there is no exception handler in the body of the method where the exception occurred, then the search for an exception handler continues up the call stack. If the top of the call stack is reached and no exception handler has been found, the default exception handler of the Java interpreter running the application is called and the program terminates.
    In Adaptive Server Anywhere, if a SQL statement calls a Java method, and an unhandled exception is thrown, a SQL error is generated.
    Error types in Java


    All errors in Java come from two types of error classes: Exception and Error. Usually, Exception-based errors are handled by error handling code in your method body. Error type errors are specifically for internal errors and resource exhaustion errors inside the Java run-time system.
    Exception class errors are thrown and caught. Exception handling code is characterized by try, catch, and finally code blocks.
    A try block executes code that may generate an error. A catch block is code that executes if the execution of a try block generates (or throws) an error.
    A finally block defines a block of code that executes regardless of whether an error was generated and caught and is typically used for cleanup operations. It is used for code that, under no circumstances, can be omitted.
    There are two types of exception class errors: those that are runtime exceptions and those that are not runtime exceptions.
    Errors generated by the runtime system are known as implicit exceptions, in that they do not have to be explicitly handled as part of every class or method declaration.
    For example, an array out of bounds exception can occur whenever an array is used, but the error does not have to be part of the declaration of the class or method that uses the array.
    All other exceptions are explicit. If the method being invoked can throw an error, it must be explicitly caught by the class using the exception-throwing method, or this class must explicitly throw the error itself by identifying the exception it may generate in its class declaration. Essentially, explicit exceptions must be dealt with explicitly. A method must declare all the explicit errors it throws, or catch all the explicit errors that may potentially be thrown.
    Non-runtime exceptions are checked at compile time. Java catches many such errors during compilation, before running the code.
    Every Java method is given an alternative path of execution so that all Java methods complete, even if they are unable to complete normally. If the type of error thrown is not caught, it's passed to the next code block or method in the stack.

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Posts
    976
    Rep Power
    20
    [img]smileys/smiley32.gif[/img] Good job man. Keep it UP


    WE WISH YOU ALL THE BEST
    SURESHKUMAR.NET TEAM

  3. #3
    Moderator
    Join Date
    Feb 2006
    Posts
    1,411
    Rep Power
    24
    hello naga



    one small reques gud that ur posting things but post properly ya



    its so clustered naga .. try to make it more readable atleast for my sake [img]smileys/smiley17.gif[/img] (hahhaa)





    bye



    sowmya




    http://livetolead.blogspot.com/
    all the best
    Arise Awake N Stop Not Until Ur Goal Is Reached!

  4. #4
    Junior Member
    Join Date
    Sep 2006
    Posts
    3
    Rep Power
    7

    Re: java notes

    Hi naga,
    Notes is good. But my suggestion is....instead of touching many topics...go deep in one topic with program ,example,why,where it is used...and all.....iam sorry.Dont mind.
    All the best.
    Last edited by jkirthi4; 22-09-06 at 01:09 AM.

  5. #5
    Moderator kiran2710's Avatar
    Join Date
    Jul 2006
    Posts
    2,157
    Rep Power
    81

    Re: java notes

    Nice post...

    Keep posting..



    Kiran








  6. #6
    Technical GURU BINNY's Avatar
    Join Date
    Feb 2006
    Location
    India
    Posts
    799
    Rep Power
    20

    Re: java notes

    HI Naga,

    Please dont post unformatted text. It is very difficult to read the content . So , I suggest u to post the content in a neatly and orderly manner.
    BINNY

  7. #7
    Senior Member
    Join Date
    Aug 2006
    Location
    Hyderabad,India
    Age
    34
    Posts
    6,052
    Rep Power
    115

    Re: java notes

    Thanks...

  8. #8
    Member
    Join Date
    Jul 2008
    Age
    28
    Posts
    90
    Rep Power
    6

    Re: java notes

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Content Relevant URLs by vBSEO 3.5.1 PL1