Class is defined using . . . . . . . .

Class statement
Object statement
Access specifier statement
Instance statement

The correct answer is A. Class statement.

A class statement is a statement that defines a class. A class is a blueprint for creating objects. It defines the properties and methods that an object will have.

An object statement is a statement that creates an object. An object is an instance of a class.

An access specifier statement is a statement that specifies the accessibility of a member of a class.

An instance statement is a statement that creates an instance of a class.

Here is an example of a class statement:

“`class Person {
String name;
int age;

void speak() {
System.out.println(“My name is ” + name + ” and I am ” + age + ” years old.”);
}
}
“`

This class defines a class called Person. The class has two properties: name and age. It also has a method called speak().

Here is an example of an object statement:

Person person = new Person();

This statement creates an object of type Person. The object is called person.

Here is an example of an access specifier statement:

public int getAge() {
return age;
}

This statement specifies that the age property is public. This means that the age property can be accessed from any other class.

Here is an example of an instance statement:

Person person = new Person();
person.speak();

This statement creates an object of type Person and then calls the speak() method on the object.

Exit mobile version