# Mini-Project - Core JAVA Hands-on solution | TCS Fresco Play

Disclaimer: The primary purpose of providing this solution is to assist and support anyone who are unable to complete these courses due to a technical issue or a lack of expertise. This website's information or data are solely for the purpose of knowledge and education.

Make an effort to understand these solutions and apply them to your Hands-On difficulties. (It is not advisable that copy and paste these solutions).

All Question of the MCQs Present Below for Ease Use Ctrl + F with the question name to find the Question. All the Best!

If you found answer for any of the questions is wrong. Please do mention in the comment section, could be useful for others. Thanks!

_________________________

1. Array Count

import java.io.*;

import java.util.*;

import java.text.*;

import java.math.*;

import java.util.regex.*;

public class Solution {

public static void main(String args[] ) throws Exception {

/* Enter your code here. Read input from STDIN. Print output to STDOUT */

int[] arr=new int[10];

for(int i=0;i<10;i++)

arr[i]=0;

Scanner sc=new Scanner(System.in);

String text=sc.next();

for(int i=0;i<text.length();i++)

{

arr[Integer.parseInt(text.substring(i,i+1))]++;

}

for(int i=0;i<10;i++)

{

if(arr[i]!=0)

System.out.println(i+": "+arr[i]);

}

}

}

2. Collections

import java.io.*;

import java.util.*;

import java.text.*;

import java.math.*;

import java.util.regex.*;

public class Solution {

public static void main(String args[] ) throws Exception {

/* Enter your code here. Read input from STDIN. Print output to STDOUT */

HashMap<Integer, String> ppl = new HashMap<Integer, String>();

Scanner sc=new Scanner(System.in);

int n=sc.nextInt();

while(n-->0)

{

// System.out.println(sc.nextInt());

int num=sc.nextInt();

String val=sc.nextLine();

// System.out.println(val);

val=val.trim();

ppl.put(num,val);

}

int num=sc.nextInt();

if(ppl.containsKey(num))

System.out.println(ppl.get(num));

else

System.out.println(-1);

}

}

3. Strings Count

import java.io.IOException;

import java.util.*;

public class Solution{

public static int charSearch(String str,char ch){

//complete the code

HashMap<Character,Integer> chrs = new HashMap<Character,Integer>();

for(int i=0;i<str.length();i++)

{

chrs.put(str.charAt(i),chrs.getOrDefault(str.charAt(i),0)+1);

}

return chrs.getOrDefault(ch,0);

}

public static void main(String[] args) throws IOException {

______________________________

If you have any queries, please feel free to ask on the comment section.
If you want MCQs and Hands-On solutions for any courses, Please feel free to ask on the comment section too.

Please share and support our page!