Page 1 of 2
1 2

Programming in JAVA

Java Coding For Interview

Exception Handling An exception is a problem that arises during the run time of a program. import java.util.*; import java.lang.*; import java.io.*; class CodeWindow { public static void main (String[] args) { int a=10,b; b=a/0; System.out.println(b); } } Output: Run time Error Exception in thread “main” java.lang.ArithmeticException: / by zeroat CodeWindow.main(Main.java:10) In the above example, …

Java Coding For Interview Read More »

Java Coding For Interview

JAVA Topic 1 JAVA Topic 2 JAVA Topic 3 The topics that are covered in this article:1. Inheritance2. Types of Inheritance in Java3. Example of Single Inheritance4. Example of Multilevel Inheritance5. Example of Hierarchical Inheritance6. Order of Constructor Calling7. Method Overriding8. Super in Inheritance9. Super without Inheritance10. Multiple Inheritance is not Supported11. Static in Java …

Java Coding For Interview Read More »

Java Coding For Interview | Codewindow.in

JAVA Topic 1 JAVA Topic 1 JAVA Topic 2 JAVA Topic 2 JAVA Topic 3 JAVA Topic 3 How to Print a Welcome message in JAVA? What is the difference between print, printf and println? package CodeWindow; public class Introduction { public static void main(String[] args) { System.out.println("Welcome to CodeWindow"); /* * System.out.println() * It …

Java Coding For Interview | Codewindow.in Read More »

Superclass variable can reference a subclass variable in java

A reference variable of a superclass can be assigned a reference to any subclass derived from that superclass. You will find this aspect of inheritance quite useful in a variety of situations. For example, consider the following: Here, weightbox is a reference to BoxWeight objects, and plainbox is a reference to Box objects. Since BoxWeight …

Superclass variable can reference a subclass variable in java Read More »