Sir in this question in the place of finding maximum age of student if we want to find total age of jisha and Eva so how to do that because in place of Max we have to take string as well as age sir its my request please let me know how to do that .
Create a class called Student with the below attributes: rollNo - int name - String branch - String score - double dayScholar - boolean The above attributes should be private, write getters, setters and parameterized constructor as required. Create class Solution with main method. Implement two static methods -findCountOfDayscholarStudents and findStudentwithSecondHighestScore in Solution class. Can you give the solution for this?
Can you please provide whole question? I would like to know sample input and output as well.and also I would like to know description of 2 static methods.
@@SadikPathan Create a class called Student with the below attributes: rollNo - int name - String branch - String score - double dayScholar - boolean The above attributes should be private, write getters, setters and parameterized constructor as required. Create class Solution with main method. Implement two static methods -findCountOfDayscholarStudents and findStudentwithSecondHighestScore in Solution class. findCountOfDayscholarStudents: This method will take an array of Student objects as an input parameter . This method will calculate and return the count of Students whose score is greater than 80 and who are all from dayScholar. If no Student scored greater than 80 and from dayScholar are present in the array of Student objects, then the method should return 0. findStudentwithSecondHighestScore: This method will take an array of Student objects as an input parameter. This method will return the object of the second highest score student from the array of Student objects who are not from the dayScholar. If no Student is a dayScholar in the array of Student objects, then the method should return null. Note : All the searches should be case insensitive. The combination of dayScholar and score for each student is always unique. The above mentioned static methods should be called from the main method. For findCountOfDayscholarStudents method - The main method should print the returned count as it is if the returned value is greater than 0, else it should print "There are no such dayscholar students". For findStudentwithSecondHighestScore method - The main method should print the rollNo, name and score in the below format from the returned object if the retuned value is not null. rollNo#name#score If the returned value is null, then it should print ”There are no student from non day scholar” Before calling these static methods in main, use Scanner object to read the values of four Student objects referring attributes in the above mentioned attribute sequence. Consider below sample input and output: Input: 1001 Ashwa IT 85 true 1002 Preeti IT 70 false 1003 Uma ECE 85 false 1004 Akash EEE 90 true Output: 2 1002#Preeti#70.0 -------------------------------------------------- Sample code snippet for reference: Please use below code to build your solution. -------------------------------------------------- import java.util.Scanner; public class Solution { public static void main(String[] args) { //code to read values //code to call required method //code to display the result } public static int findCountOfDayscholarStudents(/* required parameters to be added */) { //method logic } public static Student findStudentwithSecondHighestScore(/* required parameters to be added */) { //method logic } } class Student { //code to build the class } ------------------------------------------------- Note on using Scanner object: Sometimes scanner does not read the new line character while invoking methods like nextInt(), nextDouble() etc. Usually, this is not an issue, but this may be visible while calling nextLine() immediately after those methods. Consider below input values: 1001 Savings Referring below code: Scanner sc = new Scanner(System.in); int x = sc.nextInt(); String str = sc.nextLine(); -> here we expect str to have value Savings.Instead it may be "". If above issue is observed, then it is suggested to add one more explicit call to nextLine() after reading numeric value.
Yes you need to write in editor and not ide . So you need to write constructor , getter and setter on your own. I am writing in ide because it helps me in writing code faster because it gives suggestions.
Bhai jese aapne bola getter bhi use kr skte ho but sirf I'd, name se kaam chalega to unka bnane ka mtlb kya h code m faltu time waste h. Agr esa h to phir setter to khi use hi nhi hue to itna time kyu waste kre code likhne m
Agar name ,id,age,marks attributes ko private Declare kar diya,to hum id ,marks age ,marks ko directly access nahi karsakte(students[i].id will not work, but students[i].getId() will work because getId() method is public .).us case me hame getter and setters ki jarurat paddti hai . Class me agar koi attribute ya fir method private hai to usko hum getters and setters se hi access kar sakte hai. Lekin maine jo class banayi hai ,usme koi bhi attribute private nahi hai ,isliye mai id ko ans1.id likhke access kar paa raha hu aur ans1.getId() likhke bhi access kar paa raha hu. I hope you understand.
Agar private karne ko bola fir bhi mat karo private .aur getter setter bhi mat likho.time waste hota hai. Aise maine kiya tha ,fir bhi test cases pass ho gye the.
Good Evening Sir. Can you provide solution for the below question sir? Question 1 : Create a Class Player with below attributes: id - int country - String side - String price - double Write getters, setters and parameterized constructor as required. Create class Solution with main method. Implement static method - searchPlayerForMatch in Solution class. This method will take a String parameter along with the other parameter as array of Player objects. The method will return array of Player where the String parameter appears in the side attribute (with case insensitive search). This method should be called from main method and display the id of returned objects in ascending order. Before calling this method(searchPlayerForMatch) in the main method, use Scanner object to read values for four Player objects referring the attributes in the above sequence. then, read the value for search parameter. Next call the method searchPlayerForMatch, write the logic to sort the id in ascending order (in main method) and display the result. Consider below sample input and output: Input: 1 India Batting 2500000 2 Australia Batting 1000000 3 Srilanka Bowling 1700000 4 England Bowling 2000000 Batting Output: 1 2 -------------------------------------------------- Sample code snippet for reference: Please use below code to build your solution. -------------------------------------------------- public class Solution { public static void main(String[] args) { //code to read values //code to call required method //code to display the result } public static Player[] searchPlayerForMatch(String search, Player[] players) { //method logic } } class Player { //code to build Player class } ------------------------------------------------- Note on using Scanner object: Sometimes scanner does not read the new line character while invoking methods like nextInt(), nextDouble() etc. Usually, this is not an issue, but this may be visible while calling nextLine() immediately after those methods. Consider below input values: 22 hello Referring below code: Scanner sc = new Scanner(System.in); int x = sc.nextInt(); String str = sc.nextLine(); -> here we expect str to have value hello. Instead it may be "". If above issue is observed, then it is suggested to add one more explicit call to nextLine() after reading numeric value.
Bro ye jo parameterized constructor,getters and setters k liye jo shortcut use kiye ho double shift wo PRA exam me kr skte waisa??
PLEASE REPLY
Nahi
Can you help me to solve the error of input miss matched
I have just the the this code still error of input miss matched showed
Sir in this question in the place of finding maximum age of student if we want to find total age of jisha and Eva so how to do that because in place of Max we have to take string as well as age sir its my request please let me know how to do that .
Bro can we do it by inter max=integer_min.. U have explained in 1 video for maximum value
Sir when try to run this I got the error msg like non static variable cannot be referenced from a static contex
How resolve this error please reply sir
Please provide more content for upcoming batches ...like 2023 batch
We can solve questions in c++ language in tcs ira?
no only in python or java
brother i used your methode, program to compile ho gya but test cases run ni ho rhe,kya kru?
2nd loop.leke.complex.krdiye
Thanks yaar so much ... this question has repeated on pra 24th May
Can you please explain what ir PRA
Bro. I get an exception in "main" Java. Lang. NullpointeeEception
So what I do..
Sir, which editor you are using.
Movavi video editor
Thanks a lot for explaining it in a easy way
Very helpful sir
Bro if the output is name instead of I'd then input will be 2
String input2 = sc.nextLine( );
Is it correct input for 2
I am getting an runtime error please tell me. What should I do
you can connect with me on linkedin.
link to my linked in profile is given in the desciption of the videos on my channel.
Create a class called Student with the below attributes:
rollNo - int
name - String
branch - String
score - double
dayScholar - boolean
The above attributes should be private, write getters, setters and parameterized constructor as required.
Create class Solution with main method.
Implement two static methods -findCountOfDayscholarStudents and findStudentwithSecondHighestScore in Solution class.
Can you give the solution for this?
Can you please provide whole question?
I would like to know sample input and output as well.and also I would like to know description of 2 static methods.
@@SadikPathan Create a class called Student with the below attributes:
rollNo - int
name - String
branch - String
score - double
dayScholar - boolean
The above attributes should be private, write getters, setters and parameterized constructor as required.
Create class Solution with main method.
Implement two static methods -findCountOfDayscholarStudents and findStudentwithSecondHighestScore in Solution class.
findCountOfDayscholarStudents:
This method will take an array of Student objects as an input parameter . This method will calculate and return the count of Students whose score is greater than 80 and who are all from dayScholar.
If no Student scored greater than 80 and from dayScholar are present in the array of Student objects, then the method should return 0.
findStudentwithSecondHighestScore:
This method will take an array of Student objects as an input parameter. This method will return the object of the second highest score student from the array of Student objects who are not from the dayScholar.
If no Student is a dayScholar in the array of Student objects, then the method should return null.
Note : All the searches should be case insensitive.
The combination of dayScholar and score for each student is always unique.
The above mentioned static methods should be called from the main method.
For findCountOfDayscholarStudents method - The main method should print the returned count as it is if the returned value is greater than 0, else it should print "There are no such dayscholar students".
For findStudentwithSecondHighestScore method - The main method should print the rollNo, name and score in the below format from the returned object if the retuned value is not null.
rollNo#name#score
If the returned value is null, then it should print ”There are no student from non day scholar”
Before calling these static methods in main, use Scanner object to read the values of four Student objects referring attributes in the above mentioned attribute sequence.
Consider below sample input and output:
Input:
1001
Ashwa
IT
85
true
1002
Preeti
IT
70
false
1003
Uma
ECE
85
false
1004
Akash
EEE
90
true
Output:
2
1002#Preeti#70.0
--------------------------------------------------
Sample code snippet for reference:
Please use below code to build your solution.
--------------------------------------------------
import java.util.Scanner;
public class Solution
{
public static void main(String[] args)
{
//code to read values
//code to call required method
//code to display the result
}
public static int findCountOfDayscholarStudents(/* required parameters to be added */)
{
//method logic
}
public static Student findStudentwithSecondHighestScore(/* required parameters to be added */)
{
//method logic
}
}
class Student
{
//code to build the class
}
-------------------------------------------------
Note on using Scanner object:
Sometimes scanner does not read the new line character while invoking methods like nextInt(), nextDouble() etc.
Usually, this is not an issue, but this may be visible while calling nextLine() immediately after those methods.
Consider below input values:
1001
Savings
Referring below code:
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
String str = sc.nextLine(); -> here we expect str to have value Savings.Instead it may be "".
If above issue is observed, then it is suggested to add one more explicit call to nextLine() after reading numeric value.
The video is uploaded on my channel jahnavi.kindly watch it because I have discussed your problem in that video
but in exam ,we need to write program in notepad not this eclipse
Yes you need to write in editor and not ide .
So you need to write constructor , getter and setter on your own.
I am writing in ide because it helps me in writing code faster because it gives suggestions.
Bhai jese aapne bola getter bhi use kr skte ho but sirf I'd, name se kaam chalega to unka bnane ka mtlb kya h code m faltu time waste h. Agr esa h to phir setter to khi use hi nhi hue to itna time kyu waste kre code likhne m
Agar name ,id,age,marks attributes ko private
Declare kar diya,to hum id ,marks age ,marks ko directly access nahi karsakte(students[i].id will not work, but students[i].getId() will work because getId() method is public .).us case me hame getter and setters ki jarurat paddti hai .
Class me agar koi attribute ya fir method private hai to usko hum getters and setters se hi access kar sakte hai. Lekin maine jo class banayi hai ,usme koi bhi attribute private nahi hai ,isliye mai id ko
ans1.id likhke access kar paa raha hu aur ans1.getId() likhke bhi access kar paa raha hu.
I hope you understand.
Okk smjha lekin agr exam me attribute private krne bole or hm na krr to test case pass nhi honge?
Agar private karne ko bola fir bhi mat karo private .aur getter setter bhi mat likho.time waste hota hai.
Aise maine kiya tha ,fir bhi test cases pass ho gye the.
thank u so much bro . i have pra
Or brother 20 Dec ko IRA EXAM hua tha uska solution nhi de rhe aap? Esa kyu
Aane vale saturday ko bana dunga bro vo bhi.👍
Can u tell ans for 2aug pra? Plz
Thankyou so much!!!!!
bro is this code run in java7 or java8?
java8
Thank you 😇🤘
Well explained
Pyton code explanation plz
I am much more comfortable with java as compared to python.
Good Evening Sir. Can you provide solution for the below question sir?
Question 1 :
Create a Class Player with below attributes:
id - int
country - String
side - String
price - double
Write getters, setters and parameterized constructor as required.
Create class Solution with main method.
Implement static method - searchPlayerForMatch in Solution class.
This method will take a String parameter along with the other parameter as array of Player objects.
The method will return array of Player where the String parameter appears in the side attribute (with case insensitive search).
This method should be called from main method and display the id of returned objects in ascending order.
Before calling this method(searchPlayerForMatch) in the main method, use Scanner object to read values for four Player objects referring the attributes in the above sequence.
then, read the value for search parameter.
Next call the method searchPlayerForMatch, write the logic to sort the id in ascending order (in main method) and display the result.
Consider below sample input and output:
Input:
1
India
Batting
2500000
2
Australia
Batting
1000000
3
Srilanka
Bowling
1700000
4
England
Bowling
2000000
Batting
Output:
1
2
--------------------------------------------------
Sample code snippet for reference:
Please use below code to build your solution.
--------------------------------------------------
public class Solution
{
public static void main(String[] args)
{
//code to read values
//code to call required method
//code to display the result
}
public static Player[] searchPlayerForMatch(String search, Player[] players)
{
//method logic
}
}
class Player
{
//code to build Player class
}
-------------------------------------------------
Note on using Scanner object:
Sometimes scanner does not read the new line character while invoking methods like nextInt(), nextDouble() etc.
Usually, this is not an issue, but this may be visible while calling nextLine() immediately after those methods.
Consider below input values:
22
hello
Referring below code:
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
String str = sc.nextLine(); -> here we expect str to have value hello. Instead it may be "".
If above issue is observed, then it is suggested to add one more explicit call to nextLine() after reading numeric value.
Can you please tell me in which exam and when this question was asked?
@@SadikPathan Sir it is in TCS IPA exam but I'm unaware of which year sur
@@JAHNAVITBBTCS the video is out on my channel .
Please watch it as i have discussed your problem.
@@SadikPathan Thank you so much sir!
veryy helpful
Thank you so much!