Computer Science, asked by BrainlyPromoter, 1 year ago

If a[ ] is an array, then what does System.out.println(a) print?

Programming Language: Java
Class: 10
Chapter: Arrays

*Copied answers not allowed*​

Answers

Answered by user528
4

Answer:

it prints a[0] because by default a refers to starting address of a which is equal to a[0]

Answered by sk181231
0

Objectives

Declare, Initialize, and Use Arrays

Use Loops for Array Traversal

Pass Arrays as Parameters

Return Arrays from Methods

Understand Reference Semantics

(Optional) Use Arrays to Store and Process Data from Files

(Optional) Use Multidimensional Arrays

Assignments

Complete zyBook Chapters 13 and 14 participation and challenge activities before each class and before the Wednesday deadline of respective week

Chapter 13 zyLab activities due beginning of Week 14 and Chapter 14 zyLab activities due beginning of Week 15

Finish Project 3 (Due begining of Week 16)

Array Basics

Consider the following interaction (input in red):

How many days' temperatures? 7

Day 1's high temp: 45

Day 2's high temp: 44

Day 3's high temp: 39

Day 4's high temp: 48

Day 5's high temp: 37

Day 6's high temp: 46

Day 7's high temp: 53

Average temp = 44.6

4 days were above average.

We need to be able to read each input value twice: once to compute the average (a cumulative sum) and again to count how many were above average. We could read each value into a variable, but we don't know how many days are needed until the program runs, so we don't know how many variables to declare.

We need a way to declare many variables in one step and then be able to store and access their values.

Challenge: Is it possible to solve the above problem using only the techniques from the previous notes without using arrays? How?

Arrays

An array is an object that stores many values of the same type. An array element is one value in an array. An array index is an integer indicating a position in an array. Like Strings, arrays use zero-based indexing, that is, array indexes start with 0. The following displays the indexes and values in an array with 10 elements of type int.

index 0 1 2 3 4 5 6 7 8 9

value 12 49 -2 26 5 17 -6 84 72 3

Array declaration and creation

The syntax for declaring an array is:

type[ ] variable;

Similar questions