5.VARIABLES

After having introduction of OOPs and JVM we are now ready to learn Java programming. The ultimate aim of the reader should be that he/she is trained to give smart and efficient instructions to the computer to get his/her task done. So start grasping the concepts of the programming we are presenting and your talent will lie in your ability to apply these concepts to get a task done by a computer efficiently or solve a real-world problem. We will have to learn the basic building block of the Java programming first & the variable is one of those basic building blocks.

Analogy 10.1

We have seen this analogy in the previous chapter, whereSam’s mother is getting her task of shopping done by Sushil [Sushil] would keep the money in his purse & purse into his pants pocket. Sushil will being the items in the carry bag he is carrying. So the carry bag, purse or pocket is the container or holder which will hold or contain some tangible item like: cbi, money, fruit, vegetables etc.

Similarly in program, variable is used to store some data during program execution. This data can be a number or alphanumeric text. The variables will have some name in the program. Recall Chapter #1 where we studied how computer stores data. The computer stores data in secondary memory (like Hard disk, pendrive, memory card) if the data has to be stored permanently. While the CPU is executing your program instructions, the data which CPU is dealing with, is stored in primary memory (RAM) temporarily for execution purpose. We also read that now RAM can be visualized as shoe counter in a temple where each box containing a pair of shoes represents one binary digit.

Address 1001100
Address 21101100
Address 31101010

DO IT YOURSELF: You have already written a couple of programs on your computer & it is so assumed that you don’t fully understand what those lines mean. No problem. Gradually you will be able to understand the meaning of those lines & you will be more happier when you will learn that you have learnt new things. It’s time to write a new program. Suppose we want the computer to get this task done — add two numbers for us. We will provide those two numbers in the program …

Line #1 is the way through which we can connect our program to Java library, or any API developed by any company. Line #2 shows our class name in the program. Though you can put any name here, it is strongly suggested to name in Java as object oriented language & hence class name should try to resemble a object type in the real world. For e.g. “Harry the Addition Calculator” name means it is representing a calculator doing addition. An object of this class can be thought of the calculator in your dad’s almeirah which can do only addition. Line #3 → Curly braces are used in Java to denote the starting/meaning and ending of a block of the program. For e.g. the curly brace at Line #2 denotes that class “Addition Calculator” begins from here. Similarly Line #(18) denotes that the class is ending now have read in your mathematics algebra… Variable means something which varies, which is not constant. So here “a” is a variable which can store any data. But currently this variable is holding a constant value i.e. 256. However, “a” is a variable which means it can not only hold 256 but also 257, 1, 12, 1000 & so on. However there is a limit to what all data this variable can store. And that is determined by what is written on left hand side of “a” — “int” tells what type of data “a” can store. “int” is the defined term defined by Java device manufacturer (Oracle/Sun). So int a = 256 means we have created a variable.

Now, we understand what as variable from the side which is visible to us. But what is variable from the side which is not visible to us i.e. within computer. Let us understand —

When you run this computer program what would have happened in the backend. Java compiler along with JVM has compiled this code & presented to CPU for execution. CPU starts execution of the code. What would have happened when CPU executed line #6? In the RAM, it allocated a portion of the memory to store 256. As we just read, each memory stores data in binary format, the binary of 256 is stored in memory.

So this is how int a = 256 is stored in the memory. Obviously, CPU then is again stored in RAM & is denoted by C.

C111110100X

contains 500 in binary format.

Line #9 executes — This is class/method provided by Java library which we are just executing/reusing to display the value of C to the o/p device i.e. monitor/screen.

So, from the program, we got to know three things about int a = 256:

  • → it is called data type
  • → it is called variable name
  • → it is called constant

The maximum no. which can be put in this 1 byte space is 11111111. But the decimal equivalent value of this binary no. is 255. Then why does this data type allows only till 127 & not till 255? Think! It is because the computer has to take care of the sign of the data. It should be able to store the information whether I am storing +10 or -10; 127 or -127. So for that left most bit is kept reserved for denoting + or – sign. Remaining boxes → 7. What will be the binary decimal equivalent of 1111111? It will be 127. So if the left most digit (also called Most Significant Bit MSB) is:

  • 0 → 0111 1111 → it will be 127
  • 1 → 1111 1111 → it will be -128 – 1. You might have thought it to be -127 or 128. For this to understand we need to understand 2’s complement.

2’s complement

So by now we byte data type is storing signed integer. Since it stores negative or integer, it allows to store negative integer upto 0 – 128 & positive integer upto 127.

Signed integers are represented in 1 byte space through a method called 2’s complement. This means, a negative no. is still represented by doing …

IMP! Bring a chapter of GATE & decimal-binary conversion. Addition of binary.

Some operation on its corresponding -ve no.:

  • +ve no. → [2’s complement] → -ve no.
  • e.g. -128 … 128 → -128

How does it work?

  • Get the binary of 128, i.e. the positive integer. It will be: 1 000 000 0
  • Do the NOT of above. It will be: 0 1 0 1 1 1 1 1
  • Add 1 to above:
  • 0 1 1 1 1 1 1 1
  • + 1
  • = 1 0 0 0 0 0 0 0

So this represents -128. Please note that with -ve 1 byte, MSB will always be 1 for negative integer. Similarly 1 0 0 0 0 0 0 1 will represent -2, 1 1 1 1 1 1 1 0 will represent -2, 1 1 1 1 1 1 1 1 will represent -1.

Can 128 be stored using 1 byte? Ans is No, because its representation is 1 000 000 0 but MSB is storing the signed bit. That means it is representing -128. So the range of value which byte can store is upto 127 only for +ve numbers & the minimum will be -128 and widgeon [range].

So in summary this “byte” data type provided by Java allows to store signed numbers (i.e. it allows both +ve & -ve numbers). The range of its number it can store is from -128 to 127. Any no. outside this range cannot be accommodated in 1 byte memory space (8 bits). Having known the fact that left most bit (MSB) stores the sign information — for +ve it stores 0, for -ve it stores 1.

Test yourself: If you have understood the above concept, then tell if this program has any problem or it will work fine:

class AdditionCalculator {
    PSVM (String[] args) {
        byte firstNumber = 127;
        byte secondNumber = 1;
        byte sum = firstNumber + secondNumber;
        SOP("sum = " + sum);
    }
}

So where is the “byte” data type useful? Well it is simple. It can be used when we are handling small values in our program.

Short — It is another data type provided by Java & it is one level bigger than byte of the variable. The CPU allocates 2 bytes of memory (RAM) space for the variable created …

… with this data type.

11

This much space is allocated in memory. Remember Trick: Short = byte × 2 multiply by 2. i.e. byte takes 1 byte. Just add 1 to get that short takes 2 bytes.

Similar to byte, this data type allows us to store +ve as well as -ve numbers. i.e. Left most bits (MSB) out of those 16 boxes store the sign information — 1 for negative no. & 0 for +ve no.

DO IT YOURSELF: So now can you tell what would be the range of the numeric value the variable created with this data type allowed? < Computer science is a close relative of mathematics so apply some concepts of mathematics to get the ans > The ans is -2¹⁵ to 2¹⁵ – 1.

int — This data type is one step larger than short. I’ve seen this data type is most often used among all in the IT industry. The CPU allocates 4 bytes of memory (RAM) space for the variable created with this data type. 4 bytes mean 8×4 = 32 bits. This means 32 bits are allocated in RAM.

Remember Trick: int = short × 2. Since similar to short, this data type allows us to store +ve as well as -ve numbers. So the range of values it stores is from -2³¹ to 2³¹ – 1.

Long — This data type is one step larger than int. This stores quite a large value which int cannot hold. The CPU allocates 8 bytes of memory (RAM) space for variable created with this data type. 8 bytes means 8×8 = 64 bits. This means 64 bits are allocated in RAM.

Remember Trick: long = int × 2. Similar to int, this data type allows us to store +ve as well as -ve numbers. So the range of values it stores is from -2⁶³ to 2⁶³ – 1.

DO IT YOURSELF: So far we read about 4 data types storing different values allowing variables created with that type to have different sizes.

  • byte occupies 1 byte in memory
  • short occupies 2 bytes in memory → All support
  • int occupies 4 bytes in memory → integer
  • long occupies 8 bytes in memory → only

Write 4 programs which adds two numbers using these 4 data types. Try to use the upper range or lower range data.

OK, so now we know data types which can store integer values. But what if we want to store decimal numbers in our program? Java provides us with data types to address this problem too. What is a decimal no.? It stores both whole & what is decimal no.? It stores numbers. It has a . (dot) in its form. The number before dot represents whole no. & the number after dot represents fractional no. For e.g. 2.5 represents a decimal number where 2 is a whole no. & .5 represents 1/2 or one half of a whole.

The two data types provided by Java for storing decimal no.:
Dfloat — Just like int data type we read for integer, this data type uses 4 bytes (32 bits) in memory. How is a decimal no. stored in memory is little tricky so pay attention here.

There could be multiple ways to store the binary value of the decimal no. we are using in our program. However, computer scientists agreed on a standard way to store the binary value of a decimal no. using 32 bit memory [IEEE 754 std]. Let us consider we are using a variable of a to store decimal at:

float SumeetMarks = 8.25;

So we created a variable named SumeetMarks & it is of float data type. The constant value it stores is 8.25. So let’s see how is 8.25 is stored by our genius assistants (computer!) in its RAM.

Step 1: Get the binary of 8.25 first.
Integral part is 8. Its binary is 1000.

Decimal part is 0.25 →

  • 0.25 × 2 = 0.50 → 0 ↓
  • 0.50 × 2 = 1.00 → 1 ↓

So, the binary format of 8.25 is 1000.01

Step 2: Now, can’t we write 1000.01 (obtained binary) as 100.001 × 10¹? OR 10.0001 × 10² OR 1.00001 × 10³ → Let’s keep this notation. IEEE754 tells to confine to this notation where decimal is there is just one bit on the left of decimal point. (of course it will be always 1).

Step 3: 1.00001 × 10³ → This is called exponent


This is called significant bits

So the computer needs to come to this notation in order to understand how to populate those 32 bits. This is of the form → [1. significant bit × 10^exponent]. Now, IEEE754 says that out of 32, allocate left most bit for a sign. 1 indicates negative value & 0 indicates positive value. It as SumeetMarks is 8.25, hence at this bit will store 0. If it would have been -8.25 (can a cruel teacher do this?!), this bit will store 1.

Next 8 bit for exponent. Now in this example, exponent is 3 which is positive. But don’t you think exponent could be negative as well? Think… Suppose no. is 0.25, then its binary will be 0.01. Putting in above notation it is 1.010 × 10⁻². Which is …

in above notation is 1.010 × 10⁻². [Contd. on next notebook]


That’s the complete transcription of all 14 pages! The notes cover Java Variables, data types (byte, short, int, long, float), binary representation, 2’s complement, and IEEE 754 floating point standard.

VARIABLES PART 2:

Now is the time to fill remaining values. The vote mantis can say by ignoring past (exponent nos). No value ignored. Now we fill remaining values. We can show one displaying. Similarly binary is 0000 0000.

The us of bits in the signword allow 23 bits. 23 bits signed 6 decimal digits of precision. There is no precision 6).
(bor cpu it compute knows by design, that with this arrangement, we are exponent mantus & ixased on that
-1ST comes sterne in the
-1Q is value

We read above about exponent that 000 000 00 care spaced values. What is the specially they are keeping?
We need to store NaN (Not A Number)

A general case 11 of data and n-bits of value. On-1 Range of value like -128 to 128. Something else. To we can’t take the 0 bjea value. 12.8 let us take.

Similaarly we will show one displaying. We can’t store 12.9 in the genuine binary is 0000 0000.

So we stored exponent value of we rang [-126, 129] & the bias value is -127.
Fortunately you should be converted that 00000000 ca be used for exponent [as 5 renormalized to [-126, 127]

Convert to one example of a 5-bit converted into the 4-bit significant & 1-bit exponent format of
The value is 1.00001 X 10² → exponent value is 1 bit filled upto new are
big 0 000000 before 11
0 0 0 | 0 . 0 0 | 1 1
6-bit significant

Some straightforward cases? Contain 23 bit items so one-mapping 1/128:13 is approx -129 is approx 000 000 00 00 0 000 01

126 is ” ” ” 111 111 10
127 is ” ” ” 111 111 11

But a bad-rows here. 000 000 00 2 111 111 11 are reserved binary in & we can’t map to the range [-128, 127]. We will study what they are. used for.

We do touch restriction was not the use to exponent in the range [-126, 127]. All we can add to the no & get the binary of that no.
Fore@D of exponent would be -128 then add [128]@to -128 resulting in 0. The binary of this is 0000 0000. This will be stored in 8 bits to get the original value from the binary part & the bias no. from the binary part.

If exponent would be 127, then add 128 to 127 resulting in 255 binary of this is 1111 1111 But 0 1111 1111 0 can’t be mapped as it is observed forWhat is NaN? What it other is a unsigned operation like 0.0 divided by 0, 0 find out the value a very we, the absolute value.

NaN (1 1 1 1 1 1 1 1 1)

Sign exposed

We can represent Positive Infinity (∞) 1 0 | 1 0 1 0 1 0 1 0 1 0 1 0 | – all bits

We can represent negative Infinity (-∞) 1 1 | 1 1 1 1 1 1 1 1 1 1 | – all 0 bits AU 0b1b

There is something called Positive zero & -ye zero mean 0.0 -ye zero mean -0.0
When we compare in Java, that +0.0 = -0.0 returns true
0.0 * 0.0 = 0.0 return true But
1.0 divided by 0.0 result in +ve_pINF (∞) – 0.0 result in 1.0 divided by infinity (-∞)⁰ and in this way they are not seem to represent +ve zero (0.0) we carefully right left 0 0 0 0 0 0 | 0 | 0 | 0 / 0

About numbers 10-99. We need both capitals (lowercase), (uppercase)
char data type
When we want to store a single character we created variables with char data type. We store in a single letter on a special 16 bits of RAM to be named.

You might think how will it truly be well there is a system. Either sets containing letters & symbols from not only english but every language…
The leader is in the Unicode has a particular character (letter) assigned to it. Every Unicode character (letter) has no. To store a particular character (letter) of alphabet the corresponding assigned data type & the value is stored in the RAM. So by this it stands.

Needsay why we char data type use 2 bits & not 1 bit. It is because there are too many characters in the Unicode system.

class CharDemo
of PSVM (String [] arg)

char oruia = ‘A’;
SOP (“A=+oruia);

To exponents (Let 0 0 0 0 0 0 1 0 0)

Sign exponent:

double – just like “long” data type for storing “long” data type using 11 bits for exponent following:
1 bit CBDO for sign
11 allocate
We need to follow the significant manteus us dwelt to make the method as listing. Just bit 0.0 if the arranged stored value
Get the bias body the formula when P allocated for exponent
2^-1 = 1024 DJ: (JD)
Transform the deviand no. in modern signified by X 1 exponent
Add exponents +bjjs & get the binary allocated for exponent
Store the significant manteus in xname 52 bits

NOTE
“double” data type can provide upto 15 digits of decimal. That mean new precision.We are talking about precision and again what is the precision well, the precision means only the portion of data. float f = 4.234567891;

If we run the program, let’s get the output value so let’s check again decimal point. But float can’t store this data up to means at can’t store this data up to means. So float can’t store this data up to means. So float can’t store this data up to means accuracy. So could store exponent digits. Even the last digit if so the side is rounding. So if the precision is within 7 the value 7 digits.

So if we need more precision then we should we double gaffer at float. However double has a limitation in term of precision. The are other options for in java for even higher precision.

What else do we do we will need to store? – character. Full now we have talked.

So the exponent will be written in the box maintain a exponent that mean exponent needs to maintain a bit again if the answer is no then something else. What is the standard way of maintaining an exponent. We use something called “signed” and what it is using audits. Recall the bias. What use it? → int integer date type
What was the minimum value a variable of byte date type, store? -128
What was the maximum value a variable of byte date type, store? 129
However, the leftmost MSB is sign bit, storing the sign, number, storing in byte…

What if I say I want to store the same range i.e [-128] but the sign bit is not allowed? The negative no like -128 as well as positive no. like 127.

-128 is the smallest no. which needs to be stored in these 8 bits. And what is the smallest binary we which can be stored in these 8 bits? Obviously it would be –
0 0 0 0 0 0 0 0

So, -128 can be stored in 8-bit RAM memory

One more question that might arise what if we have a character from Unicode of bits keyboard (etc.) only few thousand characters can be stored in that, which range if I am, so to say any of the range…

ASCII sequences

A Variable of type char can store a single character from Unicode class (ASCII) valued like chat
D, storing a like the char variable “A”
char value/char = ‘A’; will assign
The char is stored in RAM using 2 bytes of memory

Execute a sequence used to store non-eight digit we present on following…

Boolean data type

For you mathematics buffs, to is a topic in algebra wherein the variable (change) had any set of value except it to value. The only possible value a boolean variable is true or false.

Non-primitive data types
We pick about primitive data types followed for call data type, i each data type allowed a official name in RAM. The variable at the location in RAM. Primitive data types used in this state directly maps to the location in RAM. Primitive

Send single bit has as address there is a place in memory & assigned as a & binary is stored into it. The main home which needs to be highlighted is that the we give the name to the path of memory which stores primitive class (type)
The part is called stack. However, there is a difference in non-primitive data type apart from primitive non-formal data type is between the variable e. Such data type are stored in stack but the value there are not actually storing are stored in stack but in separate part of the memory called HOT (Heap Object).
So the created values there you could store are stored in stack and mapped against the new variable of non-primitive data typeWhat do you think would fair been stored in RAM for the created?

Ok if data type allocated in RAM is unique address assigned to “letter a symbol” so it’s the Unicode class (BFBE) capable in to if so far otherwise

I shall with a J is 0 otherwise is the binary of 65 will stored memory

Alternatively all binary of 65 and allocated

Can you tell -two many maximum no characters can be stored in a box. (Apply) there are formula
A each box can contain all possible combination. There for formula e each letter 2^28 boxes

Hence 65^256 can be called (represent)
A for being (later) 65^256 includes digits 0-9 & so. Note that digit
on an integer box can be stored but not with a claim. ID doing
it can store 15-16 digits of specification would beMr. John and Mr. Song both won a competition. One day John was at his home won a flat. So for more details he shared at it. John & in the Toby got the important right… Small boy look at the important notes in the Toby got the popularion right? As John & at the Toby he is a primitive

Data type object

So we can say that class is a blueprint of the object. A used have created it. Please always understand it by methods we can verify which are created or the state of.

So we can see the example where pure competition organizers differ by designation is that. Speakers wise very open to people. Everyone had the Toby. People come wise very open & people. Speakers wise very open to people.

Something else… To we can take the example of the person of honor. (JVM uses a special name called “Primitive being” Or since today’s would require to

We display optimization below had limited budget. Limitation dances because organizers think. RAM is allocated upon. Someone precious from gold or each.

String is vast and very important data typed in Java. We will discuss more upon it late on.

Object

Class is not only a concept as used would which is there is a choice. Surly here all the instance same (page: All).
we brought optimization as bad combined 1000’s puzzle within
a detailed. We know bore read that all the objects in the world have specific attributes & object associated with the attributes are derived by variables of different data type. The behavior defined in Java, we define a class and by methods

Mr. John and Mr. Song both won a competition. One day John was at his home won a flat. So for more details he shared at it. John & in the Toby got the important right… Small boy look at the important notes in the Toby got the popularion right? As John & at the Toby he is a primitive

Data type object

So we can say that class is a blueprint of the object. A used have created it. Please always understand it by methods we can verify which are created or the state of.

So we can see the example where pure competition organizers differ by designation is that. Speakers wise very open to people. Everyone had the Toby. People come wise very open & people. Speakers wise very open to people.

Something else… To we can take the example of the person of honor. (JVM uses a special name called “Primitive being” Or since today’s would require to

We display optimization below had limited budget. Limitation dances because organizers think. RAM is allocated upon. Someone precious from gold or each.

String is vast and very important data typed in Java. We will discuss more upon it late on.

Object

Class is not only a concept as used would which is there is a choice. Surly here all the instance same (page: All).
we brought optimization as bad combined 1000’s puzzle within
a detailed. We know bore read that all the objects in the world have specific attributes & object associated with the attributes are derived by variables of different data type. The behavior defined in Java, we define a class and by methodsSo we can say that class is a blueprint of the object.

a used have created it. please always understand it by methods we can verify which created one… it to great things convert we can have boxed so a physical variable thing but we given to the tpye as a name port of Bill Gates is an object which type? Ame is He Boy allowed if man type. We never touched in object of man similar. woman type.

In Java, we can use the class we just defined as a data type

class TesthUm

PSVM (Str C[])

(1) Person manNumber = new Person();
new Person() of O();

(note() (Carefully) Don’t you think the statement
i A = S;
or String name = new S(my to)();
Now transformer is a variable of type Person. Person being a defined in which (1) – declared in a part of the memory is allocatedPage 9:

At more granule level, the binary of the text 0 Teoit’ will be stored in heap & address it the face will be stored stack against the variable myslueate. However, JVM uses a special memory called ‘Primitive being’ Or since today’s would denote the define bond. String variable with ie

String myName = “Albert Golowsky”;
TVM will get if either check the pool stored neither the above name of it does not simply defined in the byte

Run the program. You will be able to see the power of Shvg class. We can verify what type could store text of different… Note java has given a special capability to define Variable like about. However just like other class we never touch Handle.

Stored

One important point to note is when creating & allocating requiring memory in RAM to days. That being is our Java off we say a variable ‘s’ created in the top (byte) address during initialization. The important part is, the object variable my is allocated in cheap heap & the pointers/ of the same is stored we in the ROM. Needsay why we char data type use 2 bits & not 1 bit. It is because there are too many characters in the Unicode system.

define Variables and methods with

At the Don’t get scared with the complex format! We will understand all the basics shortly for the most minimum (lets create with the box least information from the above format

class Person
{
Store name:
int age;
word using();
boo SOP ( “if compassion is stringy”);

This contact is stored in a file/name extension as class name and vary. When we compile the TVM. Now is the date type just like primitive bad type we fare quad so far. But Since we as can say that class is a blueprint of the object.**

A user-defined data type.
Please always understand these concepts by relating it to the real world. In real world, we have objects which are generally touchable (i.e. it is a physical, tangible thing) but we cannot touch class. Class is a name given to the “type” of the object.

For e.g. Bill Gates is an object of Man type. We never touch Man. Similarly, Donald Trump is an object of Man type.

In Java, we can use the class we just defined, as a data type.

class TestRun
{
    public static void main(String[] args)
    {
        Person ramKumar = new Person();
        ramKumar.sing();
    }
}

Read carefully. Don’t you think this statement is similar to —
int a = 5;

or
String name = new String("Vijay");

Yes. ramKumar is a variable of type Person. Person is a reference data type. Just like String, when new is executed, a part of memory is allocated in heap memory as soon as new command is encountered & the reference of that part of memory is stored in stack against the variable name ramKumar.

The variable ramKumar is actually an object reference.


Interface – Just like how we define class in Java, in similar fashion we define interface.

As we understood, a class is blueprint of the object & it gives the information about the attributes & behaviour (methods) the object will have. For the class, we need to define the methods that behaviour is exhibited by the object. In other words, the method must be defined.

However, when we define an interface, we just need to provide the method name. We don’t need to provide the info how that method behaviour will be executed. This is the main difference between class & interface. In this way we can say that interface is the blueprint of the class.

ANALOGY
A simple usecase of interface can be like this: Suppose you are a business selling clothes. You have a website & you want to use (say Razorpay) as a payment method.

  1. User selects the apparel.
  2. User finalises & presses Buy Now.
  3. With the control given to Razorpay for payment. Once the payment is done, the control comes back to your website.
  4. You get the confirmation that the payment is done.
  5. You get the order processed for the customer.

For this to happen, Razorpay has defined an interface with a method sendBackConfirmation().

Now, you need to write the definition of this method in your website to update your database that the payment is done.

So in this case, Razorpay has made this interface publicly available & all those customers will need to implement the method.

void sendBackConfirmation(String msg);

The class which will implement this interface will have to provide this info like this:

class PaymentGateway implements Payment
{
    public void sendBackConfirmation(String msg) { ... }
}

Array – Array is yet another data type. A data type which stores one or more data of the same datatype.

Suppose you are a subject teacher of a class having 500 students. You want the computer to tell you whether each student passed or failed in a test. How will you tell the computer the marks of those 500 students?

We know that a variable created with primitive data types can store only one number.

int markOfStudent1 = 42;

It is not practical to create 500 such variables. So Java has a data type to our rescue — Array.

class PassOrFailTeller
{
    public static void main(String[] args) throws Exception
    {
        int[] marksOfAllStudent = new int[500];
        Scanner s = new Scanner(System.in);

        for (int i = 0; i < 500; i++)
        {
            if (marksOfAllStudent[i] < 40)
                System.out.println("Fail");
            else
                System.out.println("Pass");
        }
    }
}

We can run a loop where each iteration gives a number incremented by 1 from zero onwards & this number is used to access an element of that array.

One important point to note is when defining & allocating requiring memory in RAM to days. That being is our Java where we say a variable ‘s’ created in the top (byte) address during initialization. The important part is, the object variable my is allocated in cheap heap & the pointers/ of the same is stored we in the ROM.

Each of the memory box for an index we is entry with ‘0’ & incremented by 1 to access the data (first mark) we need to provide the index to the variable suppose you stored ‘t’ the marks of Letter like ‘Abhishek’ (index 0), aw ’32’ is (index 1), while Like ‘7’ (index 2)
Body index 3 with
(3)The ZUB owe under 69 (I…
the tD acces mark 2 you we need to provide mark 0 (SU(der))
A tD acces mark 3 body we need provide mark 0 (SU(der))

(5) Enum – Just like a class has attributes and methods. Enum too has attributes (data members) and methods. However, the attributes declared in Enum has several restrictions –

i) It is public. The attributes can be accessed outside.
ii) It is static. It is class-level, not associated with any object.
iii) It is final. It can’t be declared in a child class in a function everyday scenario.

Due to other restrictions, Enum can objects of Enum type can not be created. This enum cannot be a child of a parent class. Enum can implement Interface:

Previous Article
Next Article