Question: HCLTech | Recent Online Assessment 2026 | Java Data Encryption | Method Overloading |Latest HCLTech Placement Questions 2026 | Blood Relations & Data Sufficiency
0
Entering edit mode

Section 1: Coding Question

Question: Java: Data Encryption

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:

  1. Default Version: Takes no parameters and calculates the encrypted value as baseEncryptionValue + encryptionRatio
  2. First Overloaded Version: Accepts an integer encryptionAdjustment and calculates the encrypted value as (baseEncryptionValue + encryptionRatio) - encryptionAdjustment
  3. Second Overloaded Version: Accepts a string encryptionAdjustment, converts it to an integer, and calculates the encrypted value as (baseEncryptionValue + encryptionRatio) - encryptionAdjustment

Example: encryptionRatio = 50 baseEncryptionValue = 200 encryptionAdjustment = 14

  • Default, encryptedValue = 250
  • With the first method modification, encryptedValue = 236
  • With the second method modification, encryptedValue = 236

(Your task is to write the complete Java class implementation to pass all test cases based on these requirements).


Section 2: Verbal Reasoning (Section I)

Question 1: Blood Relations

E4 is the grandmother of F4. G4 is the sister of F4. How is E4 related to G4?

  • A. Grand daughter
  • B. Grandmother
  • C. Sister in law
  • D. Mother in law

Question 2: Blood Relations

R3 is the nephew of S3. T3 is the father of R3. How is T3 related to S3?

  • A. Brother
  • B. Uncle
  • C. Father
  • D. Cousin

Question 3: Data Sufficiency

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:

  • A. Both statements together are sufficient.
  • B. Statement I alone is sufficient.
  • C. Statement II alone is sufficient.
  • D. None of the statements alone or together are sufficient to answer the question.
ADD COMMENTlink 11 days ago Sarthak • 10
0
Entering edit mode

Problem1 -: Java: Data Encryption Solution

Topics Involved / Prerequisites

  • Object-Oriented Programming (OOP)
  • Method Overloading
  • Type Conversion (String to Integer)

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:

  • Default: Takes no parameters and returns the sum of the two base attributes.
  • Integer Parameter: Takes an integer adj, calculates the default sum, and subtracts adj.
  • String Parameter: Takes a string adj, uses Integer.parseInt() to convert the string into a usable integer, and performs the exact same subtraction logic.
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

  • Time: O(1) - All mathematical operations and the string-to-integer conversion execute in constant time.
ADD COMMENTlink 3 days ago admin 1.9k
0
Entering edit mode

Verbal Reasoning Solutions

Question 1: Blood Relations

  • Logic: If E4 is the grandmother of F4, and G4 is the sister of F4, then G4 and F4 are siblings. The grandmother of one sibling is automatically the grandmother of the other sibling. Therefore, E4 is the grandmother of G4.
  • Correct Option: B. Grandmother

Question 2: Blood Relations

  • Correct Option: A. Brother

Question 3: Data Sufficiency

  • Logic: * Statement I: States that if 5 more students join, the total is 40. This is a simple algebraic equation: X + 5 = 40, meaning X = 35. This perfectly answers the question.
    • Statement II: States the number is a multiple of 5. This could be 5, 10, 15, 35, etc. It does not provide a single definitive answer.
  • Correct Option: B. Statement I alone is sufficient.

 

ADD COMMENTlink 3 days ago admin 1.9k

Login before adding your answer.

Similar Posts
Loading Similar Posts