Java Program to Illustrates Use of Static Inner Class

This is a Java Program to Illustrates Use of Static Inner Class. We made a Outer class and define a static Inner class in it. We define a non static method as show() method in inner class and we try to call this method by inner class object and outer class object and we get … Read more

advertisement

Java Program to Illustrates Use of Abstract Class and Method

This is a Java Program to Illustrates Use of Abstract Class and Method. Here we made add() and multiply() as abstract methods in parent class which are defined in child class and we can call all these mehods via making object of child class. Here is the source code of the Java Program to Illustrates … Read more

advertisement

Constructor Chaining Program in Java

What is Constructor Chaining in Java? Constructor chaining in Java is the process of calling one constructor from another constructor within the same class or from the parent class. In Java, constructor chaining is achieved using the this() keyword, which is used to call another constructor within the same class, and the super() keyword, which … Read more

advertisement

Static Variable Program in Java

What is Static Variable in Java? A static variable in Java belongs to a class and is shared among all instances of that class. It is declared using the “static” keyword before the variable type. It’s used to maintain common data across objects of the same class and can be accessed without creating an instance … Read more

advertisement

Java Program to Demonstrate Usage of an Instance Variable in the Test Class

This is a Java Program to Demonstrate Usage of an Instance Variable x in the Test Class. Here we made a variable X as an instance variable and if we try to access that from main() directly then it will show error and it proves that all non – static things of a class always … Read more

advertisement

Java Program to Illustrate the Use of HashCode() Method

This is a Java Program to Illustrate the Use of HashCode() Method. The hashcode of a Java Object is simply a number, it is 32-bit signed int, that allows an object to be managed by a hash-based data structure. We have to implement hashcode() method of a class in such way that if two objects … Read more

advertisement

Java Program to Implement Shape Interface using Circle and Rectangle Class

This is a Java Program to Make Shape as an Interface and Implement it using Circle and Rectangle Class. Interfaces are syntactically similar to classes, but they lack instance variables, and their methods are declared without any body. Here we make interface as Shape with two methods as input() and area() which are implemented by … Read more

advertisement

String Constructor Program in Java

This is a Java Program Which has two Classes Which Initializes a String in Its Constructor. Constructor is used to initialise an object. Here we made two classes as Super and Sub class using Inheritance. We initialise two different strings in the constructors of these two classes and with the help of object of Sub … Read more

advertisement

Java Program to Swap Objects using Swap() Method

This is a Java Program to Interchange Two Employee Objects by Passing them to Swap() Method. Here we make a swap method to interchange the information of two employees using Employee Objects by passing them to swap() method. Here is the source code of the Java Program to Interchange Two Employee Objects by Passing them … Read more

advertisement

Java Program to Check Whether Which One is Executed First, Static Block or the Static Method

This is a Java Program to Check Whether Which One is Executed First , Static block or the Static Method. Static block is used to initialise the static data members dynamically. If you want to perform a task only once in life cycle of class then put that code in static block. Here is the … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.