Problem Statement: Customize a class called DataEncryption with the attributes encryptionRatio, baseEncryptionValue, and a method named encryptValue().
Implement three versions of the encryptValue() method in the DataEncryption class:
Example: encryptionRatio = 50 baseEncryptionValue = 200 encryptionAdjustment = 14
(Your task is to write the complete Java class implementation to pass all test cases based on these requirements).
E4 is the grandmother of F4. G4 is the sister of F4. How is E4 related to G4?
R3 is the nephew of S3. T3 is the father of R3. How is T3 related to S3?
The question given below is followed by two statements numbered I and II. Determine if the statements are, individually or together, sufficient to answer the question.
Question: What is the total number of students in a class?
Statements: I. If 5 more students join, the class will have 40 students. II. The number of students is a multiple of 5.
Options:
Topics Involved / Prerequisites
Overview
We need to implement a class that demonstrates polymorphism through method overloading by providing multiple ways to calculate an encrypted value.
By defining three distinct methods with the exact same name but different parameter types, Java automatically determines which logic to execute.
This allows the system to seamlessly handle default calculations, integer adjustments, and string-based adjustments without changing the method name.
Approach
1. Class Definition and Attributes
We define the DataEncryption class and declare the two required integer attributes: encryptionRatio and baseEncryptionValue. A constructor is typically added to initialize these values when an object of the class is instantiated.
2. Overloading the Methods
We create three versions of encryptValue:
public class DataEncryption {
int encryptionRatio;
int baseEncryptionValue;
public DataEncryption(int ratio, int base) {
this.encryptionRatio = ratio;
this.baseEncryptionValue = base;
}
public int encryptValue() {
return baseEncryptionValue + encryptionRatio;
}
public int encryptValue(int adj) {
return (baseEncryptionValue + encryptionRatio) - adj;
}
// Convert string to integer before subtracting
public int encryptValue(String adj) {
return (baseEncryptionValue + encryptionRatio) - Integer.parseInt(adj);
}
}Time Complexity
Verbal Reasoning Solutions
Question 1: Blood Relations
Question 2: Blood Relations
Question 3: Data Sufficiency