I used computers for 3 years now and i think its B
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.
The exercise contains 15 questions. The solution is provided for each question.
Each question contains the necessary skills you need to learn.
I have added tips and required learning resources for each question, which helps you solve the exercise. When you complete each question, you get more familiar with a control structure, loops, string, and list.
Use Online Code Editor to solve exercise questions.
Also, try to solve the basic Python Quiz for beginners
Exercise 1: Given two integer numbers return their product. If the product is greater than 1000, then return their sum
Reference article for help:
Accept user input in Python
Calculate an Average in Python
Given 1:
number1 = 20
number2 = 30
Expected Output:
The result is 600
Given 2:
number1 = 40
number2 = 30
Expected Output:
The result is 70
Explanation:
Answer:
3. alpha = {1, 5, 6, 7, 5}
Explanation:
Initially, we have that:
alpha[0] = 1;
alpha[1] = 2;
alpha[2] = 3;
alpha[3] = 4;
alpha[4] = 5;
For j higher than 2, we have that:
alpha[j - 1] = alpha[j] + 2;
So
j = 3
a[2] = alpha[3]+2 = 4 + 2 = 6;
j = 4
a[3] = alpha[4]+2 = 5+2 = 7;
The correct answer is:
3. alpha = {1, 5, 6, 7, 5}