Answer:
public class num3 {
public static String swapValues(int userVal1, int userVal2){
int temp = userVal2;
userVal2 = userVal1;
userVal1 = temp;
return(userVal1+", "+userVal2);
}
public static void main(String[] args) {
int val1 = 5;
int val2 = 8;
System.out.println("Original values");
System.out.println(val1+", "+val2);
System.out.println("Swapped Values");
System.out.println(swapValues(val1,val2));
}
}
Explanation:
- The problem is solved with Java programming language
- Define the method swapValues() to accept two ints and return a String
- Within the method body, create a temp variable to hold the value of userVal2 temporary
- Do the following re-assignment of values userVal2 = userVal1; userVal1 = temp;
- Return the concatenated String userVal1+", "+userVal2
- Create two variables and initialize them in the main method
- Output their values
- Call swapValues() aand output the swapped values
Answer:
Hi!
The correct answer is d. Neither (a) nor (b) is true.
Explanation:
First, you have to know what the scripts intend to do, and they are counting from 1 to 10 in both cases.
Table of results of class TestA at end of each iteration:
[j = 0, counter = 1]
[j = 10, counter = 2]
[j = 20, counter = 3]
[j = 30, counter = 4]
[j = 40, counter = 5]
[j = 50, counter = 6]
[j = 60, counter = 7]
[j = 70, counter = 8]
[j = 80, counter = 9]
[j = 90, counter = 10]
Table of results of class TestB at end of each iteration:
[j = 10, counter = 1]
[j = 9, counter = 2]
[j = 8, counter = 3]
[j = 7, counter = 4]
[j = 6, counter = 5]
[j = 5, counter = 6]
[j = 4, counter = 7]
[j = 3, counter = 8]
[j = 2, counter = 9]
[j = 1, counter = 10]
That's why a) and b) are false.
Maybe you want to know why using pre increments on class TestB doesn't affect the loop. The reason is that when enters in a loop, first checks the test condition and takes the decision if true or false, and last executes the incrementation step.
Coding is like doing somethin i already know but look u can search it up in Google trust me
Take an online course,or maybe do special trainings,practice and study.
Answer : Encoding
Explanation : Encoding refers to correctly coding the message so that the receiver gets the clear message without feating any misunderstanding.