1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lisov135 [29]
3 years ago
13

To print the last element in the array named ar, you can write :A. System.out.println(ar.length);

Computers and Technology
1 answer:
timofeeve [1]3 years ago
3 0

Answer:

Option (d) is the correct answer.

Explanation:

An Array is used to store multiple variables in the memory in the continuous memory allocation on which starting index value is starting from 0 and the last index value location is size-1.

In java programming language the array.length is used to tells the size of the array so when the user wants to get the value of the last element, he needs to print the value of (array.length-1) location so the correct statement for the java programming language is to print the last element in the array named ar is--

System.out.println(ar[ar.length-1]);

No option provides the above statement, so option d (None of these) is correct while the reason behind the other option is not correct is as follows--

  • Option a will prints the size of the array.
  • Option b also gives the error because length is an undeclared variable.
  • Option c will give the error of array bound of an exception because it begs the value of the size+1 element of the array.
You might be interested in
How do you recognize substances that have gone through physical or chemical changes?
Leviafan [203]
Normally  you can't.   You cannot tell if water has been frozen and then thawed.
7 0
3 years ago
Read 2 more answers
Given a vector of students, the function FinalAvg is supposed to return the average final exam score across all the students in
alexandr1967 [171]

Answer:

The C++ code is given below with appropriate comments

Explanation:

#define CATCH_CONFIG_MAIN //This tells Catch to provide a main()

#include"catch.hpp" //Header for Catch Framework

double FinalAvg( vector <int> students) // Function to calculate average.

{

double sum =0;

int i;

for( i=0;i<v.size();i++) sum+= v[i];

return v.empty() ? 0.0 : (double(sum)/ v.size());

}

vector<int> func(int argvq[ ]) // This function is made because we can not provide vector in command line argument that's why we used array which is then conerted into vector.

{

vector<int> v;

int j;

int l= sizeof(argvq)/sizeof(argvq[0]);

for(j=0;j<l;j++)

v.push_back(argq[j]);

return v;

}

TEST_CASE(" Final Average marks are computed","[func]") // TEST_ CASE macro to take one or more arguments

{

REQUIRE( func(9,5,-7) == 7); // We write our individual test assertions using the REQUIRE macro.

REQUIRE(func(2,4,6,-2) ==4);

}

Explanation Using different IDE:

#include<bits/stdc++.h>

using namespace std;

double FinalAvg(vector<int> students)

{

double sum=0;

for(int i=0;i<v.size();i++) sum+= v[i];

return v.empty() ? 0.0 : (double(sum)/v.size());

}

int main()

{

vector<int> v;

int i;

while(cin>>i&&i>0) v.push_back(i);

cout<<Final Avg(v);

return 0;

}

8 0
3 years ago
Plz go sub 2 "Shyy096" he is a 11 y/o boy and makes music fortnite vids, it would rly help him if u subscribe cuz he only has 8.
Pachacha [2.7K]

Answer:

OKK

Explanation:

5 0
2 years ago
What would a match() property that passed the expression /^[0-9]/ check for?
lord [1]

Answer:

E

Explanation:

I took the test

7 0
2 years ago
Read 2 more answers
Orifice tubes are A. coded in American models only. B. coded by number for easy identification. C. similarly but not exactly siz
timurjin [86]
I'd go for (C) similarly but not exactly sized

Basically, to explain an orifice tube in Layman’s context, it is a car’s air conditioning system and is the exact place where the cold happens. Not all orifice tubes are standard sized and this means that different model vehicles use different sizes. These tubes are often color-coded for easy identification.






8 0
2 years ago
Other questions:
  • Describe the difference between Global knowledge and personal idea. Why is it important to give credit to others by citing their
    6·1 answer
  • There are n tasks to complete. Each task first needs to be preprocessed on a supercomputer and then finished on one of n process
    12·1 answer
  • Climate is considered a(n) _______ limiting factor. (2 points)
    9·1 answer
  • Recall the problem of finding the number of inversions. As in the text, we are given a sequence of n numbers a1, . . . , an, whi
    8·1 answer
  • Using this tool to help you to visualize your slides and develop your content
    13·1 answer
  • ____ technology is the same as that used in digital watches, or the time display on a microwave oven
    14·1 answer
  • Consider Statement 1: All prime numbers greater than 3 are equal to a multiple of six, plus 1 or minus 1. Let P(x) be the statem
    7·1 answer
  • How do I create a simple percentage function to gather a score for a quiz in PHP?
    14·1 answer
  • What do other people think of e.t ( be specifc by putting a line in the story)<br><br> E.T MOVIE
    11·1 answer
  • write a program which prompts the user for a celsius temperature, convert the temperature to fahrenheit, and print out the conve
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!