0% found this document useful (0 votes)
2 views

2a.hands-On_Introduction to Java - Questions

The document outlines a hands-on training session for SDE readiness focused on Java programming, scheduled for February 13, 2025. It includes a series of easy-level coding problems that cover variable declaration, data types, conditional statements, and arithmetic operations. Participants are tasked with solving various programming challenges to enhance their Java skills.

Uploaded by

Krishna J
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

2a.hands-On_Introduction to Java - Questions

The document outlines a hands-on training session for SDE readiness focused on Java programming, scheduled for February 13, 2025. It includes a series of easy-level coding problems that cover variable declaration, data types, conditional statements, and arithmetic operations. Participants are tasked with solving various programming challenges to enhance their Java skills.

Uploaded by

Krishna J
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

HANDS-ON

SDE Readiness Training

Hands-on No. : 2a

Topic : Introduction to Java

Date : 13.02.2025

Solve the following problems

Question
Question Detail Level
No.

Declare a variable ‘bookPrice’ (Choose the right datatype). Assign

1 the value 150.50 to ‘bookPrice’. Print the price. Now, re-assign a Easy
value to ‘bookPrice’ then print ‘bookPrice’.
Create the variables for a player's name, age, height in cm, weight
in kg, rank, and mobile number, and assign the values of your
2 Easy
choice. Display the player detail. (byte, short, int, double, String
datatypes can be used).
Read a person's name first, read another person and another.
Greet the first person first, the third person second and the second
3 Easy
person last. If ‘Chloe’, ‘Joey’ & ‘Zoe’ are the inputs, then the
output will be ‘Welcome Chloe! Welcome Zoe! Welcome Joey too!’
A cashier in a shop has currency notes of denominations 10,50
and 100. If the amount to be returned is the input, find the total

4 number of currency notes of each denomination that the cashier Easy


should give to the customer. Write a program to accomplish the
above task. Assume that the input is in 10’s multiples.
Write a Java program that increments a given number. Don't use
5 arithmetic operators. Easy

Write a program to find the maximum of two integers, without


using any conditional statements. The program should utilize
6 arithmetic operations or bitwise operations to determine the Easy

larger number.

You have a green lottery ticket with three integers: a, b, and c.


The result of the ticket depends on the relationship between these

7 three numbers: Easy


1. If all three numbers are different, the result is 0.
2. If all three numbers are the same, the result is 20.

It is going to be hard but, hard does not mean impossible.


1
HANDS-ON
SDE Readiness Training
3. If exactly two numbers are the same, the result is 10.
Your task is to determine the result of the ticket based on the
values of a, b, and c.
Sample Input & Output
greenTicket(a :1, b : 2, c : 3) → 0
greenTicket(a: 2, b: 2, c: 2) → 20
greenTicket(a: 1, b:1, c: 2) → 10
You need to create a package containing a total of goal kilos of
chocolate. You have two types of chocolate bars available:
• Small bars, each weighing 1 kilo.
• Big bars, each weighing 5 kilos.
Your task is to determine how many small bars you will need to
use, assuming you always use the big bars first to reach the
8 Easy
target weight. If it is not possible to exactly match the goal weight
using these bars, return -1.
Sample Input & Output
makeChocolate(small : 4, big : 1, goal : 9) → 4
makeChocolate(small : 4, big : 1, goal : 10) → -1
makeChocolate(small : 4, big : 1, goal : 7) → 2
You are given three integer values: a, b, and c. Your task is to
return their sum, with the following condition:
• If any of the values is 13, it and all the values to its right
should not be included in the sum.
For example, if b is 13, then both b and c should not be included
9 Easy
in the sum.
Sample Input & Output
luckySum(a : 1, b : 2, c : 3) → 6
luckySum(a : 1, b : 2, c : 13) → 3
luckySum(a : 1, b : 13, c : 3) → 1
You are given three integers: a, b, and c. Your task is to return
the sum of their values after rounding each of them to the nearest
multiple of 10, based on the following rules:
1. If the rightmost digit of a number is 5 or more, round it
10 Easy
up to the next multiple of 10.
2. If the rightmost digit is less than 5, round the number
down to the previous multiple of 10.
For example:

It is going to be hard but, hard does not mean impossible.


2
HANDS-ON
SDE Readiness Training
• 15 rounds up to 20.
• 12 rounds down to 10.
Return the sum of the rounded values of a, b, and c.
Sample Input & Output
roundSum(a : 16, b : 17, c : 18) → 60
roundSum(a : 12, b : 13, c : 14) → 30
roundSum(a: 6, b : 4, c : 4) → 10

It is going to be hard but, hard does not mean impossible.


3

You might also like