Question
1. Create arrays in Java that correspond to following array categories: a) Static b) Fixed stack-dynamic c) Fixed Heap Dynamic d) Heap Dynamic (In Java
1. Create arrays in Java that correspond to following array categories: a) Static b) Fixed stack-dynamic c) Fixed Heap Dynamic d) Heap Dynamic (In Java using ArrayList) If you cannot create arrays for a category state why you cannot do so.
2. Create an enumeration type that corresponds to months. Declare variables of this type. Write a function that accepts a month as an argument and prints of the name of that month. Answer the following for languages C, C++ and Java (you need to write code for these). a. Is an enumeration constant allowed to appear in more than one type definition b. Are enumeration values coerced to integer? c. Any other type coerced to an enumeration type? d. Can you use enumeration type in array indexing?
3. With a similar notion in 2, create an associative array in Java with Map. This array will hold 15 countries and their calling codes as keys. In your program, you will get a telephone number from user as a string in +xxx-xxxxxxxxxx format. You should parse the string and find the code. Then utilizing Map in Java, print the country name that is called by the user.
4. Demonstrate the array range checking in Java by an example. Also write similar code in C and show what can go wrong if no array range checking is done.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started