2. Let data be an array of int type, with size or capacity = 5. The value of dat
ID: 3831921 • Letter: 2
Question
2. Let data be an array of int type, with size or capacity = 5. The value of data[3] after the following code executes is _____. data[0] = 2; for (int i = 1; i < 5; i++) data[i] = data[i-1] + i; (Points : 1) 2 5 8 14
Question 3.3. What is the result of 32 % 3? (Points : 1) 0 1 2 3
Question 4.4. A return statement causes execution of a function or method to _____. (Points : 1) return to the top of the loop terminate and return to where the function or method was called terminate and halt the execution of a program return to the top of the function or method
Question 5.5. Consider the C++ class declaration class Circle { private: double radius; public: Circle(); Circle(double); void setRadius(double); double getRadius(); double volume(); void print(); }; How many constructors does the class have? (Points : 1) 0 2 4 6
Question 6.6. The value of variable y after the following switch statement executes is _____. int y = 2; switch(y) { case 1: y += 1; case 2: y += 2; case 3: y += 3; break; case 4: y += 4; break; case 5: y += 5; break; default: y = 0; } (Points : 1) 0 4 7 11
Question 7.7. Consider the Java class class MyNumberClass { private int number; public MyNumberClass() { number = 0; } public MyNumberClass(int n) { setNumber(n); } public void setNumber(int n) { number = n; } public int getNumber() { return number; } public int getSuccessor() { return number+1; } public int getPredecessor() { return number-1; } public void print() { System.out.println(number); } } What will the code below print? MyNumberClass x = new MyNumberClass(5); x.setNumber(x.getSuccessor() + x.getPredecessor()); x.print(); (Points : 1) 4 5 6 10
Question 8.8. What is the range of valid subscripts for the following array? double numbers[15]; (Points : 1) 1 to 14 1 to 15 0 to 14 0 to 15
Question 9.9. Which statement tests variable x to be in the range 10 to 20, inclusive? (Points : 1) if (10 <= x && <= 20) if (10 <= x <= 20) if (10 <= x || x <= 20) if (10 <= x && x <= 20)
Question 10.10. To indicate in an UML class diagram that a member is private, use the _____ sign in front of the member name. (Points : 1) + - # ->
Explanation / Answer
2. Let data be an array of int type, with size or capacity = 5. The value of data[3] after the following code executes is _____. data[0] = 2; for (int i = 1; i < 5; i++) data[i] = data[i-1] + i;
Ans) 8
__________________
3.3. What is the result of 32 % 3?
Ans) 2
Reason: modulus operation take the remainder after division.
__________________
4.4. A return statement causes execution of a function or method to _____.
Ans) terminate and return to where the function or method was called
__________________
5.5. Consider the C++ class declaration class Circle { private: double radius; public: Circle(); Circle(double); void setRadius(double); double getRadius(); double volume(); void print(); }; How many constructors does the class have?
Ans) 2
reason: One cconstructor is having no arguments and other constructor is having double as arguement.
public: Circle();
Circle(double);
_________________________
Question 6.6. The value of variable y after the following switch statement executes is _____.
Ans) 7
Reason: As the value of y =2 the case 2 will be executed so the statement y+=2; will be executed.
so y=2+2=4.
As case 2 is not having break statement the next case (Case 3) will also executed.
so the statement y+=3 will be executed.so y=4+3=7
As the case 3 is having break then control come out of the switch case.
So finally the value of y=7
_____________________
7.7. Consider the Java class class MyNumberClass { private int number; public MyNumberClass() { number = 0; } public MyNumberClass(int n) { setNumber(n); } public void setNumber(int n) { number = n; } public int getNumber() { return number; } public int getSuccessor() { return number+1; } public int getPredecessor() { return number-1; } public void print() { System.out.println(number); } } What will the code below print? MyNumberClass x = new MyNumberClass(5); x.setNumber(x.getSuccessor() + x.getPredecessor()); x.print();
Ans) 10
__________________________
8.8)What is the range of valid subscripts for the following array? double numbers[15];
Ans) 0 to 14
reason: The array index starting from 0 to size-1
__________________________
9.9. Which statement tests variable x to be in the range 10 to 20, inclusive?
Ans) if (10 <= x && x <= 20)
______________________
10. To indicate in an UML class diagram that a member is private, use the _____ sign in front of the member name.
Ans) -
___________________Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.