In this post, you will learn to: State the use of try-catch block. Describe the use of finally block. State the flow of execution in an exception handling block. Describe the use of throw and throws keyword. Describe the use of multiple catch blocks Using the ‘try-catch’ Block Java supports exception handling mechanism. The code […]
Java
Introduction to Exceptions in Java
In this post, you will learn to: Explain the concept of Exceptions. Identify the different types of Exceptions Causes for Exceptions An exception is an abnormal condition that arises out of an extraordinary situation disrupting the flow of program’s instructions. Exceptions report error conditions in a program. In programs, exceptions can occur due to any […]
Nested Class in Java
In this post, you will learn to: Describe Nested Class. Explain Member Class. Explain Local Class. Explain Anonymous Class Nested Class A nested class is a class defined within another class. It can have access to members of the outer or enclosing class, even if the members are declared private. Nested classes can be used […]
Class Variables in Java
In this post, you will learn to: Describe class variables. Declare and access class variables. Class and instance variables. Describe static methods. Advantages and disadvantages of static methods. State the syntax of static initializers. Class Variables Class variables are declared using the static keyword. All instances of the class share the same value of the […]
Scope of Variables in Java
In this post, you will learn to: Define scope of variables. Describe primitive variables. Describe reference variables. Scope of Variables There are two types of variables in Java. These are as follows: Primitive variable Reference variable Primitive Variables The first type is Primitive variable. A Primitive variable is used to store primitive data type values. […]
Introduction to Java Interfaces
In this post, you will learn to: Discuss the concept of interfaces. Describe how to use interfaces. Explain extending interfaces. Explain IS-A relationship. Introduction to Interfaces An interface in Java is a contract that lays down rules to be followed by the types which implement it. Consider a new employee who joins an organization to […]
Using ‘final’ Keyword in Java
In this post, you will learn to: Describe final variables. Describe final methods. State the purpose of final classes. ‘final’ Variables Many programming languages have a specific keyword to define constant identifiers or to hold values that are not likely to change during the execution of the program. In Java, the final keyword is used […]
Using ‘abstract’ Keyword in Java
In this post, you will learn to: State the use of abstract methods. Explain the purpose of abstract classes. ‘abstract’ Methods When a method has only declaration and no implementation, that is, no statements in the body, then it is called an abstract. An abstract method in Java is prefixed with the abstract keyword. An […]
Overloading of Methods in Java
In this post, you will learn to: Explain the concept of overloading. Describe overloading using different number of parameters and same data types. Describe overloading using same number of parameters and different data types. Discuss constructor overloading. State the use of this keyword. Concept of Overloading Method overloading is the ability of a class to […]
Introduction to Java Inheritance
In this post, you will learn to: Explain the concept of inheritance. State the purpose of method overriding. State the use of a super keyword. Explain covariant return types. Inheritance in Real World In a family, the traits of parents are often inherited by their children. In addition to having unique traits and behavior of […]