Rectangle -width: double length: double + setWidth(w: double): void + setL ength
ID: 3700175 • Letter: R
Question
Rectangle -width: double length: double + setWidth(w: double): void + setL ength(len : double): void +get WidthO : double + getLengthO: double + getArea0: double 1. In the class diagram above, how many methods are there? a. 2 b, 3 c. 5 d. 7 2. In the class diagram above, how many public attributes are there? a. 2 b.3 C. 0 d. 5 3. In the class diagram above, how many private methods are there? a. 5 b. 2 C. d. 3 4. loops will run the body of the loop at least one time. a. For b. While c. Do while d. Switch 5. Ais an example of a loop that never ends. a. Infinite loop b. While loop c. For Loop d. Do while loopExplanation / Answer
1)c
In a class diagram, the methods are given in the second box.
2)c
In a class diagram, public attributes are represented with +.
private with - symbol. so both the existing attributes are private.
3)c
As told in the previous answer comment the private attributes are mentioned with - symbol. all the methods are having + symbol.
4)C(Do while)
other loops will first check the condition and perform the task given inside the loop.Whereas DO while loop first executes the task and then checks the condition to run the same task for the second time.
5)a
an infinite loop is a loop that never ends.
6)d
there is no problem in that syntax. A for loop is having an initial variable, exit condition and increment of the variable is also given.we can have int inside the for a loop.
7)d
all the mentioned statements are true about static methods
8)d
10>10 gives false so the loop will not execute not even once
9)d
the answer is d. using of break and continue inside a loop is not considered safe.
10)b
a try/catch block is used throw an error if something other than the expected happen.It will be always good to throw an error instead of a program crash so that the user can go and resolve the issue
11)d
12)d
13)d
14)a and d are correct. But d is good practice to create an array
That is the correct syntax to create an array
15)a
That is the correct way to use the inbuild length function for any array(name.length())
16)c
x++ means perform the current operation and then increment x by one. so the output will be 5 and then the value will be incremented by 1.try to print the x value after that statement which will give us 6
17)b
++x means to increment the value of x first and then perform any operation.
So, x will be incremented by 1 and then the system.out.println operation will be performed giving the output as 6
18)a
19)c
other 3 are correct. option c is not correct. we can not use == operator directly for object comparisons but we can do operator overloading and then use it.directly we can not use it.
20)b
we cannot give a negative index to an array declaration.
21)d
the off-by-one error means that while iterating over an array using index from 1 to N where it is actually 0 to N-1
22)c
resize is not possible. so we have to create a new one with new length and copy the contents of the old array to new array and use the remaining space.
23)a
24)c
all the others take integers only
25)d
the array declaration will be like:
access_specifier return_type method_name(parameter_type parameter_name)
protected int[] method4 int list
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.