• java

    Custom ClassLoader

    Dynamic Class Loading or Custom Class Loaders are few of the terms which is well known to a Java developer or who is touchbase with Java. now lets learn the term Class Loading and how does it work. Class Loading is a term used in Java to load Java classes at the startup, Now we have have different instances wherein we have necessity of loading a class or you can say at below instances a class can be loaded to JVM, Bootstrap, It is responsible to load java.* packages, typically it is loading rt.jar(Also called runtime jar) and i18n.jar Extensions, JDK libraries are used to load by here, normally JRE’s EXT/LIB are…

    Comments Off on Custom ClassLoader
  • java

    Java Task Scheduler with Timer.java and TimerTask.java

    Scheduling the task in java is now days getting day by day famous and we have lots of ways to schedule the task in java, below are some of the famous ways to schedule the task: Quartz Scheduler.java and SchedulerTask.java Timer.java and TimerTask.java Here we are explaining scheduling task by using Timer.java and TimerTask.java, We can schedule task with below steps: TimerTask.java is class which used to extend by Class in which run() method needs to be implement, exactly this menthod will be run in case scheduer run. Main Class is to be use, as we are using TimerExample here which will use Timer class, which will use schedule method…

  • java

    Java Concurrency by Thread or Runable

    Multithreading refers to two or more tasks executing concurrently within a single program. A thread is an independent path of execution within a program. Many threads can run concurrently within a program. Every thread in Java is created and controlled by the java.lang.Thread class. A Java program can have many threads, and these threads can run concurrently, either asynchronously or synchronously. Multi-threading has several advantages over Multiprocessing: Threads are lightweight compared to processes Threads share the same address space and therefore can share both data and code Context switching between threads is usually less expensive than between processes Cost of thread intercommunication is relatively low that that of process intercommunication…

    Comments Off on Java Concurrency by Thread or Runable
  • java

    Convert String to Date format in Java

    Java Code for Converting String to Date format: import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date; /** * * @author www.tekhnologia.com */ public class ConverterClass {        public void stringToDate(int date, int month, int year) {                SimpleDateFormat dateFormat = new SimpleDateFormat(“dd/MM/yyyy”);         String strDate = date + “/” + month + “/” + year;        try {                        Date dateForm = dateFormat.parse(strDate);            System.out.println(“New Date = ” + dateFormat.format(dateForm));                    } catch (ParseException e) {            e.printStackTrace();        }            }    public static void main(String[] args) {        new ConverterClass().stringToDate(29, 11, 1982);    }} Out put will be : New Date = 29/11/1982

    Comments Off on Convert String to Date format in Java
  • java

    Convert Date to String in Java

    Please find below the code to change Date to String: import java.text.*;import java.util.*;public class DateToString { public static void main(String[] args) { try { DateFormat formatter ;  Date date ;    formatter = new SimpleDateFormat("dd-MMM-yyyy");  date = (Date)formatter.parse("14-July-2011");    String s = formatter.format(date);  System.out.println("Date in String is : " + s);  } catch (ParseException e)  {System.out.println("Exception :"+e);  }    }} 

    Comments Off on Convert Date to String in Java
  • Exceptions,  java

    java.lang.nullpointerexception cause and resolution

    Nullpointerexception is a very common exceptions, which used to come into life of developer, troubleshoot and support have got this type of error  approx. on daily basis.Did anybody used to troubleshoot this type of error and get the exact root cause for it. No, Just fix it by any means. thats it, no here i am trying to finding out a root cause for NullPointerException. CAUSE: Null in java, Not have any method into it and when we try something like: String s = null;if(s.equals(“search anything in null”)) above line will throw a nullpointerexception as null.equals() can not be run. so to avoid this type of scenerio we should always…

    Comments Off on java.lang.nullpointerexception cause and resolution
  • Interview Questions,  java

    Interview Questions on Core Java

    I am consolidating the questions asked during the any technical interview in different top MNCs: What is the difference between and Interface and Abstract Class? Can we create an Abstract Class without any abstract Method into it? How to make a lock at class level? What are different states in Threading? Do we have alternative to Inheritance, How this alternative is useful over inheritance? What does a method or field is “static” means? What is the difference between JVM/JRE/JDK? What is Synchronization and how it works? What is the difference between ArrayList and Vector? What is the default size of ArrayList? How to synchronized Arraylist? What is the difference between Collection…

  • Interface Vs Abstract,  Interview Questions,  java

    What is difference between an Abstract class and Interface?

    Abstract Class means Blueprint of the model. Interface and Abstract classes are same functionality and do have similarities and dissimilaties too, beow are some of similarirties and dissimilarities: Similarity: Neither Abstract classes or Interface can be instantiated. Difference: A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class. Interface have all abstract method, and an abstract class may contain concreate methods to it. Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods. One Abstract method is required to make a class abstract, and all method should be abstract to…

    Comments Off on What is difference between an Abstract class and Interface?
  • java

    Core Java Undestanding

    Core Java has to do with the basic package of Java objects that are typically used for general desktop applications. These objects come in the ‘Standard Edition’ of JavaAdvanced Java could actually refer to any advanced topic having to do with Java programming– and there are many.The other packages that you will typically see being referred to in opposition to Core Java are Enterprise Java and Micro Edition. Enterprise Java is largely business and network oriented, and Micro Edition is what is typically used for hand-held devices.The diffrence is that core java is the fundamental for java that will be used in any java technology without this no one can…

    Comments Off on Core Java Undestanding