Java api represented associative array

Assignment Help Programming Languages
Reference no: EM13192591

1. Character strings in C and C++ are implemented as arrays of char. These arrays can be initialized to string constants, as in char name [] = "freddie";

The array name will have eight elements, because all strings are terminated with a null character (zero), which is implicitly supplied by the system for string constants.

Arrays of strings in C and C++ can also be initialized with string literals. In this case, the array is one of pointers to characters. For example,

char *names [] = {"Bob", "Jake", "Darcie"};

This example illustrates the nature of character literals in C and C++. In the previous example of a string literal being used to initialize the char array name, the literal is taken to be a char array. But in the latter example (names), the literals are taken to be pointers to characters, so the array is an array of pointers to characters. For example, names[0] is a pointer to the letter 'B'in the literal character array that contains the characters 'B', 'o', 'b', and the null character.

In Java, similar syntax is used to define and initialize an array of references to String objects. For example,

String[] names = ["Bob", "Jake", "Darcie"];

From above it shows one way to create an array of strings in C or C++:

Char *name[] = {"Bob", "Jake", "Darcie"};

There is another way to get a similar effect, however:

Char *name[] [7] = {"Bob", "Jake", "Darcie"};

Compare these two techniques with respect to ease of use and efficiency.

2. a. Which class (es) in Java API represented associative array?

b. Which class(es) in the C++ standard library represent associative arrays?

3. Translate the following Ada record type into Java. Your translation should be as close to the original as possible.

type Employee_Name_Type is
record
    First: String(1..20);
    Middle: String(l..10);
    Last: String(1..20);
end record;

4. Suppose that L1 is the list ((A B) C D) and L2 is the list ((E) F). give the value of each of the following LISP expression:

1. (CONS (CAR L1) (LIST (CDR L2)))

2. (CONS (CAR (CDR L2)) (CAR L1))

3. (CDR ( CONS (CAR (CONS 'G L1)) ' (H))

4. (LIST (LIST (CAR L1) L2) 'G)

5.

a. Are the unions in Modula-2 considered to be "free unions"? Explain your answer.

b. type Shape is (Circle, Triangle, Rectangle);

type Colors is (Red, Green, Blue);

type Figure (Form : Shape) is

    record

Filled : Boolean;

Color : Colors;

case Form is

     when Circle =>

Diameter : Float;

     when Triangle =>

     Left_Side : Integer;

     Right_Side : Integer;

     Angle : Float;

   when Rectangle =>

Side_1 : Integer;

Side_2 : Integer;

end case;

  end record;

Translate the Ada variant record (above) to Modula-2.

6. a. what is the purpose of the restrict keyword in C99?

b. Give an example showing how restrict is used.

7. a. Give the minimum size of the following C++ structure, assuming that char and bool values occupy one byteintand float values occupy four bytes, double values occupy eight bytes, and pointers occupy four bytes.

struct s {

    char a;

    int b;

    bool *c;

    char d[5];

    union {

  int *e[3];

  float f;

  double g;

    };

};

b. Assuming that the structure has its minimum size, what is the offset of each member from the beginning of the structure? ( The offset of a will be 0, for example.) Include the offsets of ef, and g in your answer.

Reference no: EM13192591

Questions Cloud

What is the largest area you can enclose : If you have 260 feet of fencing and want to enclose a rectangular area up against a long, straight wall, what is the largest area you can enclose?
Honorable response to the dilemmas of existence : Nietzsche argued that the most honorable response to the dilemmas of existence is to
Define what is the silver ion concentration in a solution : What is the silver ion concentration in a solution prepared by mixing 457 mL of 0.373 M silver nitrate with 475 mL of 0.442 M sodium phosphate?
Rewrite the equation with the right side completely factored : Rewrite the equation with the right side completely factored.
Java api represented associative array : Character strings in C and C++ are implemented as arrays of char and Java API represented associative array?
Religion affect the founding of the new england colonies : How did differences in religion affect the founding of the new england colonies?
What is its true course : A plane headed due east is traveling with an airspeed of 270 miles per hour. The wind currents are moving with constant speed in the direction 240°. If the ground speed of the plane is 135 miles per hour, what is its true course?
Determine aggregate supply in the long run : Now you want to "improve" the aggregate production function to increase the supply capacity of the economy. That it, you desire to move the vertical LRAS to the right on the AS/AD diagram.LIST four initiatives that you would focus upon to get the j..
How many skirts and blouses are left in the store : An apparel shop sells skirts for $45 and blouses for $35. its entire stock is worth $51, 750, but sales are slow and only half the skirts and two-thirds of the blouses are sold, for a total of $30,6000. How many skirts and blouses are left in the ..

Reviews

Write a Review

Programming Languages Questions & Answers

  Write class called flight which represents airline flight

Draw and implement the class called Flight which represents an airline flight. It must contain instance data which represents airline name (String), flight number (int), and the flight's origin city (String).

  Write program uses while loop to output all odd numbers

Write a program that uses while loop to perform the following steps: Output all the odd numbers between firstnum and secondnum inclusive.

  Draw a erd model a manufacturing company

Draw a ERD model A manufacturing company has several assembly plants in different cities. Each plant produces one product which requires certain parts in its assembly.

  Program that prompts user to enter five test scores

Write the algorithm for a program that prompts the user to enter five test scores.

  Allow customers the option of five t-shirt sizes

Allow customers the option of five T-shirt sizes and styles: XXL Short Sleeve, XL Short Sleeve, L Short Sleeve, M Short Sleeve, S Short Sleeve. Assume that each product has a unique price that is displayed when the user cliks a Buy Now button.

  Create a class named rectangle with length and width

To cover that floor with carpet that costs $8 per square foot would cost $960. (12 x 10 x8 = 960.). You should create a class named Rectangle with the following properties:

  Method takes string and integer as parameters

Write a method called multiConcat which takes a String and an integer as parameters. Return String made up of the string parameter concatenated with itself count times.

  Program for insertion sort and selection sort algorithms

Write a program involving the insertion sort, merge sort and selection sort algorithms.

  On a 3 x 4 chessboard there are 3 black knights (b b b)

On a 3 x 4 chessboard there are 3 black knights (B B B) and 3 white knights (W W W). Exchange knights in the minimum number of turns (hint: use graph representation).

  Create program which models snake-s behavior

Create a program which models snake's behavior in the given scenario: A snake is moving toward hole. Each time it moves, snake cuts distance between itself and hole by its own body length

  Sql statements coded as transaction

Write a set of 3 SQL statements coded as transaction to reflect following change: United Parcel Service has been purchased by federal Express Corporation.

  Design application to calculate and show price of order

Design the application to calculate and show the price of order, based on number of units ordered and the customer's status (either wholesaler or retailer).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd