Ads Sponsored By Google :)

Showing posts with label Core Java. Show all posts
Showing posts with label Core Java. Show all posts

Wednesday, 27 February 2013

what is|difference between set path and set classpath|settings in java|windows|xp with an example


path and classpath in java path and classpath in java path and classpath in java setting difference between path and classpath in java difference between set path and set classpath in java difference between classpath and path variable in java set path and classpath in java in windows path and classpath settings in java java path and classpath setting in windows setting up path and classpath in java setting path and classpath in java windows xp path and classpath setting for java what is path and classpath setting setting path and classpath in java with example path and classpath in java setting with example path and classpath in java setting with an example


Difference between path and classpath settings ?

Path:
    Path settings are works at operating system level.
    When any exe file or command file or bat file etc.., are not recognized by operating system    
    then we need to do path setting to the location of that file.
    If we use any class in java program which is not a part of java API then we need to do 
    classpath setting to the file which contains that class.

For Example:
   To set path for file like Java API as follows:

     Set path=” C:\Program Files\Java\jdk1.7.0\bin”;.;

Classpath:

Classpath settings works at JVM level.

Mostly we are going to set jar file or jars files  in the classpath because a jar file or jars files contains collection java classes. If we want to use oracle co-operation given Jdbc driver software or thin driver software then we need to set OJDBC14.jar

For Example:

Wednesday, 30 January 2013

can we|i|you override|overload static method in java


can we override static method in java can i override static method in java can you override static method in java can we overload static method in java can i overload static method in java can you overload static method in java


Can we override static method in java?

      A static method is not belongs to an object and there is no notion for this nor super in 
 a static method. A static method is a global function. Hence there is also no occurrence 
 of polymorphism and method override make no sense.

Can we overload static method in java?

Overloading static method In Java
   Yes, we can overload static method in Java. In terms of method overloading static method 
   are just like normal methods and in order to overload static method you need to provide   
  another static method with same name but different method signature. Static overloaded  
  method are resolved using Static binding during compile time. Overloading method in Java 
  is completely different than overriding method and as discussed in our last article we cannot     
 override static method in java but we can certainly overload static method in Java. 

The Following Example Illustrate the Static method overloading

   //StaticOverloading.java

      public class StaticOverloading {

       public static void main(String args[]) {
           fun1("javajavax"); //will call static method with one String argument
           fun1("
javajavax", "welcome to"); //overloaded static method will be call    

       }

    
        //static method which will be overloaded
      

      public static void greet(String name){
          System.out.println("Hello " + name);
      }
  
      //Another static method which overload above Hello method
      //This shows that we can overload static method in Java
   
       public static void fun(String name, String greeting){
           System.out.println(greeting + " " + name);
       }


   }

    Output
    Hello JavaJavax
     Welcome to JavaJavax

how can we call main method explicitly or not with example


can we call main method explicitly or not how can we call main method in java can we call main method explicitly or not with example

  Can we call main method explicitly or not ?
   
      Yes, it is possible we can call main method from static block.

  For Example :
        
           public class Demo2
        {
              static                
            {
              String s[]={};
             main(s);
             main(s);
           }
           public static void main(String args[])
         {
           System.out.println(“ THIS IS MAIN METHOD”);
          }
        
}

  Output:
   THIS IS MAIN METHOD
   THIS IS MAIN METHOD

Tuesday, 29 January 2013

What is|are User|custom defined exception in java handling example guidelines|steps for developing


 user defined exception user defined exception in  java   example user defined exception in java user defined exception handling in java user defined exception java java user defined exception example custom defined exception what is user defined exception handling in java custom defined exception in java custom defined exception in java with example guidelines for developing exception handling in java what are the guidelines for developing exception handling in java steps for developing exception handling in java what are the steps for developing exception handling in java steps for developing exception in java

   User Defined Exception / Custom-defined Exceptions:   

          User Defined Exceptions are those which are developed by java programmer and   
     supplied as apart of    their project to deal with common specific problems.

   In order to develop user defined Exception Handling based applications, as a programmer, we come across three stages they are.

1)     User defined Exception sub classes
2)     User defined General / Common classes
3)     User defined Specific Classes


  1) User defined Exception sub classes:

     Guide Lines / Steps For Developing User Defined Exceptions:

      1) Choose an appropriate package for placing user defined Exceptions sub classes for 
    common access and   ensure package statement must be First executable statement.

      2) Choose an appropriate user defined class and ensure whose modifier must be public 
    and this class is going to called user defined exception subclass.

     3) Whatever class is selected in step 2 it must extends either Java.lang.RuntimeException  
    or java.lang.Exception for gaining the power for stop the program execution abnormally 
    whenever the application user enter’s invalid input’s.
       
      Hence step2 is known as User –defined Exception sub class.

    4) Each and every User defined Exception subclass must contain parameterized constructor 
    by taking string as parameter.Here String parameter represents nature of the message.

   5) Each and every  user-defined Exception parameterized constructor either 
    java.lang.RuntimeException or java.lang.Exception by using super(String message).

    2)  Development of User defined General Class:
               User defined general class makes use of user defined Exception sub class 3)   

         3) Development of User defined Specified Class:
                 This development is used by individual programmer and this class makes use of 
          user defined general classes and user defined Exception sub classes





LinkWithin