Java General

Java Marker interfaces

Following table gives all the list of Java Marker interfaces. Maker interface name Functionality 1. java.io.Serializable the object is serialized 2. java.lang.Cloneable the object is cloned 3. javax.servlet.SingleThreadModel only one object of the servlet for one request is created 4. javax.ejb.EnterpriseBean the object can participate in transactions 5. java.util.RandomAccess the elements of the data structure …

Java Marker interfaces Read More »

What is Marker Interface in Java?

1. What is marker interface? By usage, a marker interface does not contain any methods or variables. It is completely empty interface and for this reason also known as empty interface. See these two marker interface definitions in Java API. java.lang.Cloneable and java.io.Serializable are two marker interfaces often used. See the output screen. No methods …

What is Marker Interface in Java? Read More »

Why Java does not support Multiple Inheritance?

Java does not support Multiple Inheritance: Java designer, Mr.James Gosling, committed to keep Java very simple to practice even for novices; infact, it is one of goals and features of Java language. Towards this goal, he avoided multiple inheritance, operator overloading, pointers and prototype declaration etc. which adds unnecessary problems in coding like making the …

Why Java does not support Multiple Inheritance? Read More »

Why Java does not support operator overloading?

Java does not support operator overloading: Java is relatively a very simple language to use compared C/C++ with the non-support of complex and confusing features like pointers, multiple inheritance and operator overloading. These features are rarely used in practice and at the same time poorly understood by the language beginners. Every operator has a good …

Why Java does not support operator overloading? Read More »

Differences between StreamTokenizer and StringTokenizer in Java

Breaking the data into independent pieces is known as tokenization. For example, breaking a sentence into different words is known as tokenization. To do the job, Java comes with two tokenizers – StringTokenizer to tokenize a string and StreamTokenizer to tokenize a stream of data coming from I/O stream classes. Both are for very different …

Differences between StreamTokenizer and StringTokenizer in Java Read More »

Java newInstance

With Java newInstacnce() of class Class, we can create an object as you will do with new keyword. Example on Java newInstance public class Student { int marks; public void display() { System.out.println(“Hello 1”); } public static void main(String args[]) throws InstantiationException, IllegalAccessException, ClassNotFoundException { Student std1 = new Student(); std1.marks = 50; Class cls1 …

Java newInstance Read More »

Java Parse String to Date

Sometimes, it is also needed to convert String to Date; we have seen earlier how to convert Date to String. Now Parse String to Date is done. Following code gets you the conversion of string to date. We use SimpleDateFormat class method parse(). Example on Parse String to Date import java.util.Date; import java.text.SimpleDateFormat; import java.text.ParseException; …

Java Parse String to Date Read More »