Answer:
public class ArithmeticMethods
{
public static void main(String[] args) {
int number1 = 7;
int number2 = 28;
displayNumberPlus10(number1);
displayNumberPlus10(number2);
displayNumberPlus100(number1);
displayNumberPlus100(number2);
displayNumberPlus1000(number1);
displayNumberPlus1000(number2);
}
public static void displayNumberPlus10(int number){
System.out.println(number + 10);
}
public static void displayNumberPlus100(int number){
System.out.println(number + 100);
}
public static void displayNumberPlus1000(int number){
System.out.println(number + 1000);
}
}
Explanation:
Inside the main:
Initialize two integers, number1 and number2
Call the methods with each integer
Create a method called displayNumberPlus10() that displays the sum of the given number and 10
Create a method called displayNumberPlus100() that displays the sum of the given number and 100
Create a method called displayNumberPlus1000() that displays the sum of the given number and 1000
Select one:
a. 1 or 2
b. 2
c. 3
d. 1
e. None
Answer:
b. 2
Explanation:
As we know operator + is supported by the class.Since we know that the + operator binary operator means it needs two operands to work upon it cannot work on one operand.++ operator is unary operator it works on one operand only.
For example:-
a+b
a++.
Hence we conclude that the answer is 2.
Answer:A,B,E
Explanation:
Because I just took the quiz
Answer:
I think the last 1 or the 2nd one
Explanation:sorry if im wrong TwT
false
11. According to the unit, which of the following is an important first step in any creative endeavor? (1 point)
pre-production
post-planning
delegating tasks
sending emails
Answer:
See explaination
Explanation:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <sstream>
using namespace std;
// structure to hold the word, frequency and list of lines in which word appears
struct wordFrequency
{
string word;
int frequency;
vector<int> lineNumber;
};
// main method
int main()
{
// input file name. You can change the input file name if your file name is different
string inputFileName = "data.txt";
// creating a map class object to hold words uniquely
map<string, wordFrequency> map_word;
// ifstream class object to open and read from file
ifstream fin(inputFileName);
// validating if file is opened or not
if (!fin.is_open())
{
cout << "Error in opening file!";
exit(1);
}
// string to hold line from file
string line;
// int variable to keep track of line number
int lineNumber = 0;
// fetching lines from file
while (getline(fin, line))
{
// increasing the lineNumber count because we fetch another line
++lineNumber;
// breaking a line into words using stringstream class object
string word;
stringstream iss(line);
// iterating over all the words in a line
while (iss >> word)
{
// if the word is not in the map then we create and add a new pair
auto it = map_word.find(word);
if (it == map_word.end())
{
// creating a new struct object to store new word
wordFrequency w;
w.word = word;
w.frequency = 1;
w.lineNumber.push_back(lineNumber);
map_word.insert({word, w});
}
else
{
// if the word is already there then incresing frequency and push line number into list
it->second.frequency += 1;
it->second.lineNumber.push_back(lineNumber);
}
}
}
// closing the input file
fin.close();
// creating a new output file
ofstream fout("WordFrequency.txt");
if (fout.is_open())
{
// iterating over a map
for (auto word : map_word)
{
// writing data to a output file
fout << "Word is : " << word.second.word << endl;
fout << "Frequency is : " << word.second.frequency << endl;
fout << "Appears in line : ";
for (auto i : word.second.lineNumber)
{
fout << i << " ";
}
fout << endl
<< endl;
}
// closing output file
fout.close();
}
else
{
cout << "Error! Not able to create output file!";
}
}
Answer:
a. cout<<hidden(15,10)<<endl;
output = 5
b. cout << compute(3, 9) << endl;
output=3
c. cout << hidden(30, 20) << " " << compute(10, hidden(30, 20)) << endl;
output = 10
d. x = 2; y = 8; cout << compute(y, x) << endl;
output= 8
Explanation:
solution a:
num1= 15;
num2= 10;
according to condition 1, num1 is not greater than 20. In condition 2, num2 is also not greater than 20.
so,
the solution is
return num1 - num2 = 15 - 10 = 5
So the output for the above function is 5.
solution b:
as in function there are two integer type variables named as one and two. values of variables in given part are:
one = 3
two = 9
secret = one = 3
for (int i= one + 1 = 3+1 = 4; i<=9%2=1; i++ )
9%2 mean find the remainder for 9 dividing by 2 that is 1.
// there 4 is not less than equal to 1 so loop condition will be false and loop will terminate. statement in loop will not be executed.
So the answer will be return from function compute is
return secret ;
secret = 3;
so answer return from the function is 3.
solution c:
As variables in first function are num1 and num2. the values given in part c are:
num1 = 30;
num2= 20;
According to first condition num1=30>20, So,
num1= num2/10
so the solution is
num1 = 20/10 = 2
now
num1=2
now the value return from function Hidden is,
return num1*num2 = 2* 20 = 40
Now use the value return from function hidden in function compute as
compute(10, hidden(30, 20))
as the value return from hidden(30, 20) = 40
so, compute function becomes
compute(10, 40)
Now variable in compute function are named as one and two, so the values are
one= 10;
two = 40;
as
secret = one
so
secret = 10;
for (int i= one + 1 = 10+1 = 11; i<=40%2=0; i++ )
40%2 mean find the remainder for 40 dividing by 2 that is 0.
// there 11 is not less than equal to 0 so loop condition will be false and loop will terminate. statement in loop will not be executed.
So the answer will be return from function compute is
return secret ;
secret = 10;
so answer return from the function is 10.
solution d:
Now variable in compute function are named as one and two, so the values are
one = y = 8
two = x = 2
There
Secret = one = 8;
So
for (int i= one + 1 = 8+1 = 9; i<=2%2=0; i++ )
2%2 mean find the remainder for 2 dividing by 2 that is 0.
// there 9 is not less than equal to 0 so loop condition will be false and loop will terminate. statement in loop will not be executed.
So the answer will be return from function compute is
return secret ;
secret = 8;
so answer return from the function is 8.
(B) Man-in-the-middle attack
(C) Smurf attack
(D) Format string attack
(E) Denial of service attack
Answer:D)Format string attack
Explanation:
Format string attack is the type of attack that causes to change the application functioning .This attack access the memory of the string library. It occurs while the submission of the string as input and then gets tested due to application command.
Other options are incorrect because these are the attacks that don't happens in the application for the alteration of the flow. Thus, the correct option is option(D).