Answer:
public class Leo{
public String method1(){
return "Jack 1 Leo 1";
}
public String method2(){
return "Don 2 Jack 2";
}
public String method3(){
return "Jack 3 Leo 3 Don 2";
}
public String toString(){
return "Jack 3 Leo 1"
}
}
public class Jack extends Leo{
}
Explanation:
Leo is the parent class and jack inherits all of its attributes from Leo
So when you call the following code in the main method:
Jack j = new Jack();
System.out.println(j.method1);
it should print Jack 1 Leo 1
This is because the program first checks if method 1 exists in the Jack class
Because it doesn't exist it then goes to the parent class which is Leo.
And in the Leo class method1 displays "Jack 1 Leo 1 "
So it prints that
Answer:
21212122121221212211212121212212121Explanation:
Here's the complete question below that clarifies what you need to do
<u>Explanation</u>:
"In this task, we will study the performance of public-key algorithms. Please prepare a file ( message.txt) that contains a 16-byte message. Please also generate an 1024-bit RSA public/private key pair. Then, do the following:
1)Encrypt message.txt using the public key; save the the output in message_enc.txt.
2)Decrypt message_enc.txt using the private key.
3)Encrypt message.txt using a 128-bit AES key.
<em><u>Compare the time spent on each of the above operations, and describe your observations. If an operation is too fast, you may want to repeat it for many times, i.e., 5000 times, and then take an average.</u></em>
<em><u> After you finish the above exercise, you can now use OpenSSL's speed command to do such a benchmarking. Please describe whether your observations are similar to those from the outputs of the speed command?</u></em>
Answer:
Each object of this class has its own copy of GREETING
Explanation:
option c: Each object of this class has it’s own copy of GREETING
This is the only false statement. When a variable is preceded by the Static key word only one copy of that variable is created, no matter the amount of object created from the instance of that class.
option a: Each object of this class can access GREETING, this is true.
option b: The value of GREETING can’t be changed in any methods, this is true because GREETING is preceded by the keyword final.
option d: GREETING.length() = 2, this is true because the method length() is use to get the length of the string "Hi" which is 2.
option e: GREETING.toUpperCase() = "HI", this is also true because the method toUpperCase() convert all the character of "Hi" to uppercase.
Note: All these are peculiar to java programming language.
Answer:
#include<iostream>
using namespace std;
class Money{
private:
int dollars;
int cents;
public:
Money(int d=0, int c=0){
setDollar(d);
setCent(c);
}
void setDollar(int d){
dollars = d;
}
void setCent(int c){
cents = c
}
int getDollar() {
return dollars;
}
int getCent() {
return cents;
}
double getMoney(){
return (dollars + (cents/100));
}
};
// testing the program.
int main(){
Money Acc1(3,50);
cout << M.getMoney() << endl;
Money Acc2;
Acc2.setDollars(20);
Acc2.setCents(30);
cout <<"$" << Acc2.getDollars() << "." << Acc2.getCents() << endl;
return 0;
}
Explanation:
The C++ source code defines the Money class and its methods, the class is used in the main function as a test to create the instances of the money class Acc1 and Acc2.
The object Acc2 is mutated and displayed with the "setDollar and setCent" and "getDollar and getCent" methods respectively.