Computer Science, asked by michaelgodrick24, 8 months ago

the
variable in
Identify the scope of
the jollowing pseudo code and write
its output
color := Red
mycolor():
g:Green
print colon, b, g
my favcolor():
print color, b
my color()
print color​

Answers

Answered by Anonymous
0

Answer:

A data type is a set of values and a set of operations defined on those values. The primitive data types that you have been using are supplemented in Java by extensive libraries of reference types that are tailored for a large variety of applications. In this section, we consider reference types for string processing and image processing.

Strings. You have already been using a data type that is not primitive—the String data type, whose values are sequences of characters. We specify the behavior of a data type in an application programming interface (API). Here is a partial API for Java’s String data type:

String API

The first entry, with the same name as the class and no return type, defines a special method known as a constructor. The other entries define instance methods that can take arguments and return values.

using a reference data type

Declaring variables. You declare variables of a reference type in precisely the same way that you declare variables of a primitive type. A declaration statement does not create anything; it just says that we will use the variable name s to refer to a String object.

Creating objects. Each data-type value is stored in an object. When a client invokes a constructor, the Java system creates (or instantiates) an individual object (or instance). To invoke a constructor, use the keyword new; followed by the class name; followed by the constructor’s arguments, enclosed in parentheses and separated by commas.

Invoking instance methods. The most important difference between a variable of a reference type and a variable of a primitive type is that you can use reference-type variables to invoke the instance methods that implement data-type operations (in contrast to the built-in syntax involving operators such as +* that we used with primitive types).

Now, we consider various string-processing examples.

Data-type operations. The following examples illustrate various operations for the String data type.

String operations

Code fragments. The following code fragments illustrate the use of various string-processing methods.

String code fragments

Genomics. Biologists use a simple model to represent the building blocks of life, in which the letters A, C, G, and T represent the four bases in the DNA of living organisms. A gene is a substring that represents a functional unit of critical importance in understanding life processes. PotentialGene.java takes a DNA string as an argument and determines whether it corresponds to a potential gene based on the following criteria:

It begins with the start codon ATG.

Its length is a multiple of 3.

It ends with one of the stop codons TAG, TAA, or TGA.

It has no intervening stop codons.

Color. Color valuesJava's Color data type represents color values using the RGB color model where a color is defined by three integers (each between 0 and 255) that represent the intensity of the red, green, and blue components of the color. Other color values are obtained by mixing the red, blue and green components.

The Color data type has a constructor that takes three integer arguments. For example, you can write

Similar questions