Interviews - C# Corner

Rohit Gupta
What are the major components of Java Class?
By Rohit Gupta in Java onSep 10 2019
  • Vijay Kumari
    Sep, 2019 16

    There are three major components of class in Java.

    1) Variable
    Variable is a reserved memory location to hold a value. In other words, when we want to store any value and give it a name, that value takes a reserved space in memory and it’s called as a variable.

    2) Constructor
    A constructor is like a special method in Java, which is used to initialize an object of a Java class and Constructor is very important for every Java class and if we don’t declare the constructor, the compiler creates a default constructor of a Java class.

    A constructor must be the same name of a Java class. It does not have a return type.

    3) Method
    A method is a block of code which only runs when it is called. You can pass data, known as parameters, into a method. Methods are used to perform certain actions, and they are also known as functions.

    For a detailed tutorial on Java classes Components, Visit
    https://www.c-sharpcorner.com/article/a-complete-java-classes-tutorial/

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS