Which of the following is considered as a blue print that defines the variables and methods common to all of its objects of a specific kind?

Options
- Object
- Class
- Method
- Real data types


CORRECT ANSWER : Class

Discussion Board
e

d

dick 10-24-2022 10:09 PM

Classes

Classes in Java is a blue print from which individual objects are created. For example:

public class Dog{
String breed;
int age;
String color;

void barking(){
}

void hungry(){
}

void sleeping(){
}
}

The class consists of the following variable types:

1. Local variables: Variables defined inside methods, constructors or blocks are called local variables. It will be declared and initialized within the method and it will be destroyed when the method has completed.

2. Instance variables: are variables within a class but outside any method. These variables are instantiated when the class is loaded. Instance variables can be accessed from inside any method, constructor or blocks of that particular class.

3. Class variables: are variables declared with in a class, outside any method, with the static keyword.

A class can have any number of methods to access the value of various kinds of methods.

Rohit Sharma 07-29-2014 03:44 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement