0% found this document useful (0 votes)
26 views5 pages

Java Proctored Assessment Solutions

The document provides solutions for a Java Proctored Assessment held on January 15th, including code examples for two programming questions. The first question involves printing characters at odd positions in a string, while the second question requires creating a Sim class with specific attributes and methods to filter and sort Sim objects based on given criteria. The solutions include complete Java code for both problems, demonstrating the implementation of the required functionalities.

Uploaded by

hemanthnk04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views5 pages

Java Proctored Assessment Solutions

The document provides solutions for a Java Proctored Assessment held on January 15th, including code examples for two programming questions. The first question involves printing characters at odd positions in a string, while the second question requires creating a Sim class with specific attributes and methods to filter and sort Sim objects based on given criteria. The solutions include complete Java code for both problems, demonstrating the implementation of the required functionalities.

Uploaded by

hemanthnk04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

2/19/25, 7:59 PM java pa15 jan | Solutions

This site was designed with the .com website builder. Create your website today. Start Now

SOLUTIONS

0
Join Telegram Group Donation Here PAYTM

HOME Previous PA HOME Software Foundation Java Software Foundation -Python Donation OPA May - July Java PA Answer More

Java Proctored Assessment Programming solution 15th January



Question 1.

To print characters at odd position of a string

input: Matrix
output : Mti

Solution:

import [Link];
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
String str = [Link]();
for (int i = 0; i < [Link](); i+=2) {
[Link]([Link](i));
}
[Link]();
}
}

Output:

Example 1:
Matrix
Mti
Example 2:
[Link] 1/5
2/19/25, 7:59 PM java pa15 jan | Solutions

This site was designed with the .com website builder. Create your website today. Start Now

Hi how are you?


H o r o?

Question 2.

Create a Sim class with 5 attributes and also write getter ,setter
methods.
Implement a method which takes array of sim objects as first parameter , string circle
as a second parameter and a double ratePerSecond as third parameter.
This method should return an array of the
objects which containing second parameter and less than the third
parameter and also the balance value of those objects must be in descending order.
In the main method we have to display the id attribute values of the array

input:

1
jio
430
1.32
mumbai
2
idea
320
2.26
mumbai
3
airtel
500
2.54
mumbai
4
vodafone
640
3.21
mumbai
mumbai
3.4

output:

4
3
1
2
[Link] 2/5
2/19/25, 7:59 PM java pa15 jan | Solutions

This site was designed with the .com website builder. Create your website today. Start Now
Solution:

import [Link];
public class SimCard {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
Sim[] sim = new Sim[4];
for (int i = 0; i < [Link]; i++) {
int simId = [Link]();[Link]();
String name = [Link]();
double balance = [Link]();[Link]();
double ratePersecond = [Link]();[Link]();
String circle = [Link]();
sim[i] = new Sim(simId, name, balance, ratePersecond,
circle);
}
String circle1 = [Link]();
double ratePerSecond1 = [Link]();
Sim[] result = find(sim, circle1, ratePerSecond1);
for (int i = 0; i < [Link]; i++) {
[Link](result[i].getSimId());
}
[Link]();
}
public static Sim[] find(Sim[] sim, String circle1, double
ratePerSecond1) {
Sim[] temp;
int j = 0;
for (int i = 0; i < [Link]; i++) {
if (sim[i].getCircle().equals(circle1) &&
sim[i].getRatePersecond() < ratePerSecond1) {
j++;
}
}
temp = new Sim[j];
j=0;
for (int i = 0; i < [Link]; i++) {
if (sim[i].getCircle().equals(circle1) &&
sim[i].getRatePersecond() < ratePerSecond1) {
temp[j++] = sim[i];
}
}
for (int i = 0; i < j - 1; i++) {
for (int k = 0; k < j - 1; k++) {
if (temp[k].getBalance() < temp[k +
1].getBalance()) {
Sim a temp[k];
[Link] 3/5
2/19/25, 7:59 PM java pa15 jan | Solutions
Sim a = temp[k];
This site was designed with the .com website builder. Create your website today. Start Now
temp[k] = temp[k + 1];
temp[k + 1] = a;
}
}
}
return temp;
}
}
class Sim {
private int simId;
private String name;
private double balance;
private double ratePersecond;
private String circle;
public Sim(int simId, String name, double balance, double
ratePersecond, String circle) {
[Link] = simId;
[Link] = name;
[Link] = balance;
[Link] = ratePersecond;
[Link] = circle;
}
public int getSimId() {
return simId;
}
public void setSimId(int simId) {
[Link] = simId;
}
public String getName() {
return name;
}
public void setName(String name) {
[Link] = name;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
[Link] = balance;
}
public double getRatePersecond() {
return ratePersecond;
}
public void setRatePersecond(double ratePersecond) {
[Link] = ratePersecond;
}
public String getCircle() {
[Link] 4/5
2/19/25, 7:59 PM java pa15 jan | Solutions
public String getCircle() {
This site was designed with the .com website builder. Create your website today. Start Now
return circle;
}
public void setCircle(String circle) {
[Link] = circle;
}
}

©2018 by The real one. Proudly created with [Link]

[Link] 5/5

You might also like