{"id":12010,"date":"2022-08-29T11:53:58","date_gmt":"2022-08-29T06:23:58","guid":{"rendered":"https:\/\/blog.guvi.in\/?p=12010"},"modified":"2025-10-14T12:03:24","modified_gmt":"2025-10-14T06:33:24","slug":"tcs-aspire-basic-programming-quiz-questions","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/tcs-aspire-basic-programming-quiz-questions\/","title":{"rendered":"Top 10 TCS Aspire Basic Programming Quiz Questions And Answers"},"content":{"rendered":"\n<p><strong>Got a call letter from TCS? Then you might be looking for TCS Aspire Basic Programming Quiz Questions and Answers. Don&#8217;t you? <\/strong>Because Aspire is&nbsp;a mandatory learning program for all recruits of IT and EIS. <\/p>\n\n\n\n<p>TCS Aspire is an initial online interactive learning program. TCS Aspire is meant for everyone, especially for someone who is not from a programming background. <\/p>\n\n\n\n<p>After four tedious years of Engineering, you might find the newly acquired workspace a bit overwhelming. So, through Aspire, you can brush up on your<strong><em> basic software engineering concepts and expand your soft skills.<\/em><\/strong> <\/p>\n\n\n\n<p>Firstly, to unlock your Aspire, you should clear a simple quiz exam followed by <strong><em>two<\/em><\/strong> completions, viz.<strong><em> Introduction to Computer Systems and Basics of Programming. <\/em><\/strong><\/p>\n\n\n\n<p>So, Aspire will include courses on some chapters and then quizzes. After mastering those chapters, you will have quizzes for each chapter. <\/p>\n\n\n\n<p>Once you have given all the chapter quizzes, the course completion quiz is there. Let&#8217;s look at some of the <strong>top TCS Aspire Basic Quiz Programming Questions and Answers<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Some of the top TCS Aspire Basic Quiz Programming Questions and Answers<\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\"><strong> Q1. Given a string in Roman no format (s), your task is to convert it to an integer. Various symbols and their values are given below.<\/strong><\/h3>\n\n\n\n<p>I 1<\/p>\n\n\n\n<p>V 5<\/p>\n\n\n\n<p>X 10<\/p>\n\n\n\n<p>L 50<\/p>\n\n\n\n<p>C 100<\/p>\n\n\n\n<p>D 500<\/p>\n\n\n\n<p>M 1000<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/h4>\n\n\n\n<p><strong>Constraints:<\/strong> 1&lt;=roman no range&lt;=3999<\/p>\n\n\n\n<p><strong>Example 1:<\/strong><\/p>\n\n\n\n<p><strong>Input:<\/strong> s = V<\/p>\n\n\n\n<p><strong>Output:<\/strong> 5<\/p>\n\n\n\n<p><strong>Example 2:<\/strong><\/p>\n\n\n\n<p><strong>Input:<\/strong> s = III<\/p>\n\n\n\n<p><strong>Output<\/strong>: 3<\/p>\n\n\n\n<p><strong>Case 1<\/strong><\/p>\n\n\n\n<p><strong>Case 2<\/strong><\/p>\n\n\n\n<p><strong>Input (stdin)<\/strong>: V<\/p>\n\n\n\n<p><strong>Output (stdout)<\/strong>: 5<\/p>\n\n\n\n<p><strong>Input (stdin)<\/strong>: X<\/p>\n\n\n\n<p><strong>Output (stdout)<\/strong>: 10<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Code:<\/strong><\/h3>\n\n\n\n<p>import java.util.*;<\/p>\n\n\n\n<p>import java.io.*;<\/p>\n\n\n\n<p>class Main{<\/p>\n\n\n\n<p>static int value(char r)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; if (r == &#8216;I&#8217;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; if (r == &#8216;V&#8217;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 5;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; if (r == &#8216;X&#8217;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 10;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; if (r == &#8216;L&#8217;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 50;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; if (r == &#8216;C&#8217;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 100;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; if (r == &#8216;D&#8217;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 500;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; if (r == &#8216;M&#8217;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1000;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; return -1;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/h4>\n\n\n\n<p>public static void getNumber(String s){<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; int res=0;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; for(int i=0;i&lt;s.length();i++){<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int&nbsp; s1= value(s.charAt(i));<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(i+1&lt;s.length()){<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int&nbsp; s2=value(s.charAt(i+1));<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(s1&gt;=s2){<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res+=s1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res=res+s2-s1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res+=s1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(res);<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>public static void main(String [] args){<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; Scanner sc= new Scanner(System.in);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String s=sc.next();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Main.getNumber(s);<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\"><strong>Q2. The longest sequence of consecutive one&#8217;s after flipping a bit<\/strong><\/h3>\n\n\n\n<p>Given an integer &#8216;n&#8217; and you are allowed to flip exactly one bit. Write a function to find the length of the longest sequence of consecutive 1\u2019s you can create. Consider the size of the integer to 32 bits. <\/p>\n\n\n\n<p>For example: Consider n=1775, its binary representation is 11011101111. After flipping the highlighted bit, we get consecutive 8 bits (of 1\u2019s) that is 11011111111. <\/p>\n\n\n\n<p>Hence the output is 8. Consider n=15, its binary representation is 01111. After flipping the highlighted bit, we get consecutive 5 bits (of 1\u2019s) i.e., 11111. Hence the output is 5. Function Specification:- Give definition to: int flipBit(unsigned int n);<\/p>\n\n\n\n<p><strong>Format:<\/strong><\/p>\n\n\n\n<p><strong>Input:<\/strong> Input is being fetched from the command line arguments. The only argument is an integer n.<\/p>\n\n\n\n<p><strong>Output:<\/strong> The output will be the length of the longest subsequence of consecutive 1\u2019s.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example:<\/strong><\/h4>\n\n\n\n<p><strong>Input:<\/strong> 1775<\/p>\n\n\n\n<p><strong>Output:<\/strong> 8<\/p>\n\n\n\n<p>Case 1<\/p>\n\n\n\n<p><strong>Input (stdin)<\/strong>: 1775<\/p>\n\n\n\n<p><strong>Output (stdout)<\/strong>: 8<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/h4>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Code:<\/strong><\/h3>\n\n\n\n<p>import java.util.Scanner;<\/p>\n\n\n\n<p>class Main<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>&nbsp;&nbsp;static int max(int a, int b)<\/p>\n\n\n\n<p>&nbsp;&nbsp;{<\/p>\n\n\n\n<p>if (a &gt; b)<\/p>\n\n\n\n<p>&nbsp;&nbsp; return a;<\/p>\n\n\n\n<p>return b;<\/p>\n\n\n\n<p>&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;static int longestSequence(int n)<\/p>\n\n\n\n<p>&nbsp;&nbsp;{<\/p>\n\n\n\n<p>&nbsp; if(~n==0)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; return 32;<\/p>\n\n\n\n<p>int curLen=0,prevLen=0,maxLen=0;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/h4>\n\n\n\n<p>while(n!=0)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if((n&amp;1)==1)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; curLen++;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prevLen=(n &amp; 2)==0?0:curLen;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; curLen=0;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxLen=max(curLen+prevLen,maxLen);<\/p>\n\n\n\n<p>&nbsp; &nbsp; n=n&gt;&gt;1;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>return maxLen+1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;public static void main(String args[])<\/p>\n\n\n\n<p>&nbsp;&nbsp;{<\/p>\n\n\n\n<p>Scanner sc = new Scanner(System.in);<\/p>\n\n\n\n<p>int n = sc.nextInt();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(longestSequence(n));<\/p>\n\n\n\n<p>&nbsp;&nbsp;}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Q3. Infinite Supply of Coins<\/strong><\/h3>\n\n\n\n<p>Given a value N, find the number of ways to make a change for N cents. If we have an infinite supply of each S = {S1, S2,.., Sm} valued coins. The order of coins doesn\u2019t matter.<br><\/p>\n\n\n\n<p><strong>Constraints:<\/strong><\/p>\n\n\n\n<p>S &lt;= 10<\/p>\n\n\n\n<p>N &lt;= 10<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example:<\/strong><\/h4>\n\n\n\n<p><strong>Input:<\/strong><\/p>\n\n\n\n<p>3<\/p>\n\n\n\n<p>1 2 3<\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p><strong>Output:<\/strong> 4<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Explanation:<\/strong><\/h5>\n\n\n\n<p>N = 4 and S = {1,2,3}, there are four solutions: {1,1,1,1}, {1,1,2}, {2,2}, {1,3}.<\/p>\n\n\n\n<p>So the output should be 4.<\/p>\n\n\n\n<p>Case 1<\/p>\n\n\n\n<p>Case 2<\/p>\n\n\n\n<p><strong>Input (stdin)<\/strong><\/p>\n\n\n\n<p>3<\/p>\n\n\n\n<p>1 2 3<\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p><strong>Output (stdout)<\/strong>: 4<\/p>\n\n\n\n<p><strong>Input (stdin)<\/strong><\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p>2 5 3 6<\/p>\n\n\n\n<p>10<\/p>\n\n\n\n<p><strong>Output (stdout)<\/strong>: 5<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Code:<\/strong><\/h4>\n\n\n\n<p>import java.lang.*;<\/p>\n\n\n\n<p>import java.io.*;<\/p>\n\n\n\n<p>class Main<\/p>\n\n\n\n<p>&nbsp;{<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static void main (String[] args) throws Exception{<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; BufferedReader br = new BufferedReader(new InputStreamReader(System.in));<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; StringBuilder op = new StringBuilder();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int l = Integer.parseInt(br.readLine());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int coin[] = new int[l];<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String[] s = br.readLine().split(&#8221; &#8220;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int i=0; i&lt;l; i++)coin[i] = Integer.parseInt(s[i]);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int N = Integer.parseInt(br.readLine());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int[][] dp = new int[l+1][N+1];<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int i=0; i&lt;=l; i++)dp[i][0]=1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int i=1; i&lt;=l; i++){<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int j=1; j&lt;=N; j++){<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(coin[i-1] &lt;= j){<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dp[i][j] = dp[i-1][j]+dp[i][j-coin[i-1]];<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }else{<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dp[i][j]=dp[i-1][j];<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; op.append(dp[l][N]);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(op);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\"><strong>Q4. The prime number using the square root<\/strong><\/h3>\n\n\n\n<p>Given a positive integer N, check if the number is prime or not.<\/p>\n\n\n\n<p><strong>Constraint:<\/strong> 1 &lt; N &lt; 106<\/p>\n\n\n\n<p><strong>Example 1:<\/strong><\/p>\n\n\n\n<p><strong>Input<\/strong>: 11<\/p>\n\n\n\n<p><strong>Output:<\/strong> The given number is a prime number.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example 2: <\/strong><\/h4>\n\n\n\n<p><strong>Input:<\/strong> 15<\/p>\n\n\n\n<p><strong>Output:<\/strong> Given number is not a prime number<\/p>\n\n\n\n<p>Case 1<\/p>\n\n\n\n<p>Case 2<\/p>\n\n\n\n<p><strong>Input (stdin):<\/strong> 11<\/p>\n\n\n\n<p><strong>Output (stdout)<\/strong>: The given number is a prime number<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Code:<\/strong><\/h4>\n\n\n\n<p>import java.util.*;<\/p>\n\n\n\n<p>class Main {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static void main (String[] args) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; Scanner sc=new Scanner(System.in);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; int n;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; n=sc.nextInt();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; int flag=1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; for(int i=2;i*i&lt;=n;i++)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(n%i==0)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flag=0;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; if(flag==1)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Given number is a prime number&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; else<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Given number is not a prime number&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"428\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/08\/image-20-1200x428.png\" alt=\"TCS Aspire basic programming quiz questions and answers\" class=\"wp-image-12036\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/08\/image-20-1200x428.png 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/08\/image-20-300x107.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/08\/image-20-768x274.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/08\/image-20-1536x548.png 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/08\/image-20-150x54.png 150w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/08\/image-20.png 2000w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\"><strong>Q5. Read the following problem and code it:<\/strong><\/h3>\n\n\n\n<h3 class=\"wp-block-heading has-small-font-size\"><strong>Check one of the top-asked TCS Aspire Basic Programming Quiz Questions And Answers below<\/strong><\/h3>\n\n\n\n<p style=\"font-size:16px\">Azad\u2019s mother gave him Rs 100, so he decided to buy some chocolates. He went to a shop that only has chocolates of Rs 3 and 7, so it now depends on Azad\u2019s mood on how many chocolates he will buy. <\/p>\n\n\n\n<p style=\"font-size:16px\">Maybe he will not buy single chocolate. Can you tell whether he has visited the same shop, from the remaining amount? If N (0 \u2264 N \u2264 100) is equal to the possible remaining amount he has after he came from that shop, then print 1 or else 0.<\/p>\n\n\n\n<p><strong>Format:<\/strong><\/p>\n\n\n\n<p><strong>Input:<\/strong> The first line of the input contains a single integer T denoting the number of test cases. The first line of each test case contains N, denoting the remaining amount.<\/p>\n\n\n\n<p><strong>Output:<\/strong> For each test case, the output is 0 or 1.<\/p>\n\n\n\n<p><strong>Constraints:<\/strong><\/p>\n\n\n\n<p>1 \u2264 T \u2264 101<\/p>\n\n\n\n<p>0 \u2264 N \u2264 100<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/h4>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<p><strong>Input:<\/strong><\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p>93<\/p>\n\n\n\n<p>97<\/p>\n\n\n\n<p>94<\/p>\n\n\n\n<p>99<\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-group has-ast-global-color-4-background-color has-background is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p>1<\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>0<\/p>\n<\/div><\/div>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Explanation:<\/strong><\/h5>\n\n\n\n<p>100 &#8211; (0 * 3 + 1 * 7) = 93, so the output is 1.<\/p>\n\n\n\n<p>100 &#8211; (1 * 3 + 0 * 7) = 97, so the output is 1.<\/p>\n\n\n\n<p>100 &#8211; (2 * 3 + 0 * 7) = 96, so the output is 1.<\/p>\n\n\n\n<p>It is not possible, so the output is 0.<\/p>\n\n\n\n<p>Case 1<\/p>\n\n\n\n<p>Case 2<\/p>\n\n\n\n<p><strong>Input (stdin)<\/strong><\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p>93<\/p>\n\n\n\n<p>97<\/p>\n\n\n\n<p>94<\/p>\n\n\n\n<p>99<\/p>\n\n\n\n<p><strong>Output (stdout)<\/strong><\/p>\n\n\n\n<div class=\"wp-block-group has-ast-global-color-4-background-color has-background is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p>1<\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>0<\/p>\n<\/div><\/div>\n\n\n\n<p><strong>Input (stdin)<\/strong><\/p>\n\n\n\n<p>3<\/p>\n\n\n\n<p>99<\/p>\n\n\n\n<p>55<\/p>\n\n\n\n<p>26<\/p>\n\n\n\n<p><strong>Output (stdout)<\/strong><\/p>\n\n\n\n<div class=\"wp-block-group has-ast-global-color-4-background-color has-background is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p>0<\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>1<\/p>\n<\/div><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Code:<\/strong><\/h4>\n\n\n\n<p>import java.util.*;<\/p>\n\n\n\n<p>class Main {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static void main (String[] args) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; Scanner sc=new Scanner(System.in);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int t=sc.nextInt();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; while(t&#8211; &gt; 0){<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int n=sc.nextInt();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; boolean sieve[]=new boolean[101];<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; for(int i=0;i&lt;101;i++){<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; sieve[i]=false;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sieve[100]=true;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 99; i &gt;= 0; i&#8211;) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (i+3 &lt;= 100 &amp;&amp; sieve[i+3]) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sieve[i] = true;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (i+7 &lt;= 100 &amp;&amp; sieve[i+7]) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sieve[i] = true;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(sieve[n]?1:0);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\"><strong>Q6. Implement two stacks using an array<\/strong><\/h3>\n\n\n\n<p>Write a program to implement the two stacks using one array. Consider the size of an array as 1000.<\/p>\n\n\n\n<p><strong>Code:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-group has-ast-global-color-4-background-color has-background is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p>import java.util.Scanner;<\/p>\n\n\n\n<p>public class Main {<\/p>\n\n\n\n<p>&nbsp;&nbsp;public static void main(String args[]) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; Scanner sc = new Scanner(System.in);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; TwoStacks st = new TwoStacks(1000);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int size1 = sc.nextInt();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; size1; i++)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; st.push1(sc.nextInt());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int size2 = sc.nextInt();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; size2; i++)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; st.push2(sc.nextInt());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Stack 1 Elements: &#8220;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; st.print1();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Stack 2 Elements: &#8220;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; st.print2();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int deleteFirst = sc.nextInt();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; while (deleteFirst&#8211; &gt; 0)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; st.pop1();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Stack 1 Elements: &#8220;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; st.print1();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int deleteSecond = sc.nextInt();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; while (deleteSecond&#8211; &gt; 0)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; st.pop2();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Stack 2 Elements: &#8220;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; st.print2();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; sc.close();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;static class TwoStacks {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int size;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int top1, top2;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int arr[];<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; TwoStacks(int n) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; arr = new int[n];<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; size = n;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; top1 = -1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; top2 = size;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; void push1(int x) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; if (top1 &lt; top2 &#8211; 1) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; top1++;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; arr[top1] = x;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; else<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Stack Overflow&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; void push2(int x) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; if (top1 &lt; top2 &#8211; 1) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; top2&#8211;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; arr[top2] = x;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; else<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Stack Overflow&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int pop1() {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; if (top1 &gt;= 0) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int x = arr[top1];<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; top1&#8211;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; return x;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; else<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Stack underflow. pop from stack 1 failed&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; return 0;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int pop2() {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; if (top2 &lt; size) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int x = arr[top2];<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; top2++;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; return x;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; else<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Stack Underflow&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; return 0;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; void print1() {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int temp = top1;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; while (temp &gt;= 0) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.print(arr[temp] + &#8221; &#8220;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; temp&#8211;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.println();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; void print2() {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; int temp = top2;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; while (temp &lt; size) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.print(arr[temp] + &#8221; &#8220;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; temp++;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; System.out.println();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>}<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\"><strong>Q7. Write a program to check whether the given parenthesis is balanced or not.<\/strong><\/h3>\n\n\n\n<p><strong>Code:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-group has-ast-global-color-4-background-color has-background is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<p>import java.util.*;<\/p>\n\n\n\n<p>public class Main {<\/p>\n\n\n\n<p>public static boolean areBracketsBalanced(String expr) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; Stack&lt;Character&gt; stack= new Stack&lt;&gt;();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; expr.length(); i++)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char x = expr.charAt(i);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (x == &#8216;(&#8216; || x == &#8216;[&#8216; || x == &#8216;{&#8216;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stack.push(x);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (stack.isEmpty())<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char check;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (x) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case &#8216;)&#8217;:<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; check = stack.pop();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (check == &#8216;{&#8216; || check == &#8216;[&#8216;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case &#8216;}&#8217;:<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; check = stack.pop();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (check == &#8216;(&#8216; || check == &#8216;[&#8216;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case &#8216;]&#8217;:<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; check = stack.pop();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (check == &#8216;(&#8216; || check == &#8216;{&#8216;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; return stack.isEmpty();<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>public static void main(String[] args)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; Scanner s=new Scanner(System.in);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; String expr = s.next();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; if (areBracketsBalanced(expr))<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System. out.println(&#8220;Balanced &#8220;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; else<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Not Balanced &#8220;);<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>}<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\"><strong>Q8. Write a program, to sum up all the elements in a tree.<\/strong><\/h3>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<p><strong>Input:<\/strong><\/p>\n\n\n\n<p>6<\/p>\n\n\n\n<p>3<\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p>2<\/p>\n\n\n\n<p>-1<\/p>\n\n\n\n<p><strong>Output:<\/strong> The Sum of all nodes are 16<\/p>\n\n\n\n<p>Case 1<\/p>\n\n\n\n<p>Case 2<\/p>\n\n\n\n<p><strong>Input (stdin)<\/strong><\/p>\n\n\n\n<p>6<\/p>\n\n\n\n<p>3<\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p>2<\/p>\n\n\n\n<p>-1<\/p>\n\n\n\n<p><strong>Output (stdout)<\/strong>: The Sum of all nodes is 16<\/p>\n\n\n\n<p><strong>Input (stdin)<\/strong><\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>2<\/p>\n\n\n\n<p>3<\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p>5<\/p>\n\n\n\n<p>-1<\/p>\n\n\n\n<p><strong>Output (stdout)<\/strong>: The Sum of all nodes is 15<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\"><strong>Q9. Read the following TCS Aspire question<\/strong><\/h3>\n\n\n\n<p>Now, Terrace Gardens is transferring from manual to automated systems to provide services efficiently to a corporate company. At this stage, the terrace gardens are looking for a console application. First, let&#8217;s concentrate on the registration part. When a new Guest\/Customer comes to book a room, we need to record the details. <\/p>\n\n\n\n<p>Create a Class called Customer and get the following details from the user: Name Address Contact Email update Proof type Proof id Create Appropriate Getters and Setters in the customer class and member functions: void Register(String name, String address, String contactNumber, String email, String proofType, String proofID) Generate an id for the Guest \/Customer and give it to him. Print all the details given by the customer. <\/p>\n\n\n\n<p>Create a class Main with data members, get input in the Main class, and pass it to the customer class using setters. String name (consists of only alphabets, No special Characters allowed) String address (can contain alphanumeric characters and Hyphen (-) symbol ) String contactNumber (can contain only numbers) String email(should contain @ symbol) String proofType(contains only alphabets) String proofID(can consists of alphanumeric characters alone) Print Registration successful or Failed. If Successful print details otherwise print the reason like &#8220;Invalid Name&#8221;<\/p>\n\n\n\n<p><strong>Sample Input\/Output 1:<\/strong><\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the number<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">1<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the name<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Vijay<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the address<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Chennai<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the contact number<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">9876543210<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the email<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">vijay@raghav.com<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the ProofType<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">id<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the proof ID<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">998877665544<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">RegistrationSuccessfull<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Your Details:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Vijay<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Chennai<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">9876543210<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">vijay@raghav.com<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">998877665544<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Your id is 1<br><\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Sample Input\/Output 2:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">TCS Aspire basic programming quiz questions and answers;<\/h4>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the number Customer<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">2<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the name<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Vijay1<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the address<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Chennai<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the contact number<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">9876543210<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the email<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">vijay@raghav.com<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the ProofType<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">id<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the proof ID<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">998877665544<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Invalid Name<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Registration Failed<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the name<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Vijay<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the address<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Chennai<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the contact number<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Contact<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the email<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">vijay@raghav.com<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the ProofType<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">id<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the proof ID<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">998877665544<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Invalid Contact Number<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Registration Failed<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Case 1<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Input (stdin)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">1<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Vijay<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Chennai<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/h5>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">9876543210<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">vijay@raghav.com<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">aadhar<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">998877665544<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Output (stdout)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the number of Customers<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the name<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the address<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the contact number<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the email<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the ProofType<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the proof ID<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Registration Successfull<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Your Details:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Vijay<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Chennai<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">9876543210<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">vijay@raghav.com<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">aadhar<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">998877665544<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Your id is 1<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">import java.util.*;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">class Customer<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">String name;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">String address;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">String contactNumber;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">String email;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">String proofType;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">String proofID;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">int ncount=0,x=1;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">void Register(String name,String address,String contactNumber,String<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">email, String proofType, String proofID)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">int i,ncheck=0,adcheck=0,check=0,echeck=0,ptcheck=0,pidcheck=0;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">for(i=0;i&lt;name.length();i++)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">if(Character.isLetter(name.charAt(i)))<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">ncheck++;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">for(i=0;i&lt;address.length();i++)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">if((Character.isLetter(address.charAt(i)))||(Character.isDigit(address.charAt(i)))||(address.charAt(i)==&#8217;-&#8216;))<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">adcheck++;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">for(i=0;i&lt;contactNumber.length();i++)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">if(Character.isDigit(contactNumber.charAt(i)))<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">check++;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">for(i=0;i&lt;email.length();i++)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">if((email.charAt(i)==&#8217;@&#8217;)||(email.charAt(i)==&#8217;.&#8217;))<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">echeck++;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">for(i=0;i&lt;proofType.length();i++)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">if(Character.isLetter(proofType.charAt(i)))<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">ptcheck++;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">for(i=0;i&lt;proofID.length();i++)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">if((Character.isLetter(proofID.charAt(i)))||(Character.isDigit(proofID.charAt(i))))<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">pidcheck++;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">if(ncheck!=name.length())<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Invalid Name\\nRegistration Failed&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">else if(adcheck!=address.length())<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Invalid Address\\nRegistration Failed&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">else if(check!=contactNumber.length())<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/strong><\/h5>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Invalid Contact Number\\nRegistration Failed&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">else if(echeck!=2)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Invalid Email\\nRegistration Failed&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">else if(ptcheck!=proofType.length())<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Invalid ProofType\\nRegistration Failed&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">else if(pidcheck!=proofID.length())<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Invalid ProofId\\nRegistration Failed&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">else{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Registration Successfull\\nYour Details:\\n&#8221;+name+&#8221;\\n&#8221;+address+&#8221;\\n&#8221;+contactNumber+&#8221;\\n&#8221;+email+&#8221;\\n&#8221;+proofType+&#8221;\\n&#8221;+proofID+&#8221;\\nYour id is &#8220;+x);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">x++;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">class Main extends Customer{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public static void main (String[] args) {<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Scanner s=new Scanner(System.in);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Main ob=new Main();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Enter the number of Customers&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">int x=s.nextInt();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">int k=0;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">while(k&lt;x){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Enter the name&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">ob.name=s.next();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Enter the address&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">ob.address=s.next();<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/h5>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Enter the contact number&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">ob.contactNumber=s.next();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Enter the email&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">ob.email=s.next();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Enter the ProofType&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">ob.proofType=s.next();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">System.out.println(&#8220;Enter the proof ID&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">ob.proofID=s.next();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">ob.Register(ob.name,ob.address,ob.contactNumber,ob.email,ob.proofType,ob.proofID);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">k++;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Q10. Read and code the answer<\/strong><\/h3>\n\n\n\n<p>Implement the inheritance concept. Create four classes namely Main, Bike, Sportbike and Scooter. Here Main class contains String name; String colour; Float cc; Integer speed; Double price; Integer manufacturerDiscount; Integer weight; public Bike(String name, String colour, Float cc, Integer speed, Double price) { this.name = name; this.color = color; this.cc = cc; this.speed = speed; this.price = price; } Bike class contains: private String color; private String name; private Float cc; private Integer speed; private Double price; <\/p>\n\n\n\n<p>Here Bike is the base class and SportBike, the scooter is the subclass. public class SportBike extends Bike { public SportBike(String name, String colour, Float cc, Integer speed, Double price, Integer manufacturerDiscount) {} } public class Scooter extends Bike { public Scooter(String name, String colour, Float cc, Integer speed, Double price, Integer weight) {} } Use the super reference to do the things already done by the superclass.<\/p>\n\n\n\n<p class=\"has-ast-global-color-5-background-color has-background\"><strong>Sample Input and Output 1:<\/strong><\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Name of the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Ducati<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Colour of the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Red<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Capacity(CC) of the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">400<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Speed of the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">550<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Price of the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">100000<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Discount on the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">9500<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the details of the Scooter<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Name of the Scooter:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Bajaj<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Colour of the Scooter:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Grey<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Capacity(CC) of the Scooter:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">110<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Speed of the Scooter:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">120<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Price of the Scooter:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Discount on the scooter:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">4500<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">45000<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Weight of the scooter:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">250<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Sports Bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Name: Ducati<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Colour: Red<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Capacity: 400.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Speed: 550<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Price: 100000.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Manufacturer Discount: 9500<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Sports Bike price is 90500.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Scooter :<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Name: Bajaj<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Colour: Grey<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Capacity: 110.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Speed: 120<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Price: 45000.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Weight: 250<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Manufacturer Discount: 4500<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">The scooter price is 40500.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the details of the Sports Bike<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Case 1<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Input (stdin)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Ducati<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Red<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">400<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">550<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">100000<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">9500<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Bajaj<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Grey<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">110<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">120<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">45000<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">4500<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">250<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Output (stdout)<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the details of the Sports Bike<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Name of the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Colour of the bike :<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Capacity(cc) of the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Speed of the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Price of the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Discount on the bike:<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Enter the details of the Scooter<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Name of the Scooter<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Colour of the Scooter :<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Capacity(CC) of the Scooter :<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Speed of the Scooter :<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Price of the Scooter :<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Discount on the scooter :<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Weight of the scooter :<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Sports Bike :<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Name: Ducati<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Colour: Red<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Capacity: 400.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Speed: 550<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Price: 100000.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Manufacturer Discount: 9500<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Sports Bike price is 90500.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Scooter:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/h4>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Name: Bajaj<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Colour: Grey<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Capacity: 110.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Speed: 120<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Price: 45000.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Weight: 250<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">Manufacturer Discount: 4500<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">The scooter price is 40500.0<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">import java.util.Scanner;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">class Bike{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private String colour;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private String name;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private Float cc;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private Integer speed;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private Double price;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private int weight;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">\/\/GETTERS<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public String getName(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return name;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public String getColor(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return colour;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public float getCC(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return cc;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public int getSpeed(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return speed;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public Double getPrice(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return price;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public int getWeight(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return weight;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">\/\/SETTER<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public void setName(String name){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.name=name;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public void setColor(String color){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.color=color;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public void setCC(float cc){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.cc=cc;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public void setSpeed(int speed){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.speed=speed;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public void setPrice(Double price){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.price=price;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public void setWeight(int weight){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.weight=weight;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">class Sportbike extends Bike{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private int discount;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private double price1;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public Sportbike(String name, String colour, Float cc, Integer speed, Double price, int discount){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setName(name);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setColor(color);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setCC(cc);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.price1=price;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.discount=discount;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setSpeed(speed);<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/h4>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setPrice(price-discount);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public int getDiscount(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return discount;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public double getPrice1(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return price1;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public String toString()<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return &#8220;Name : &#8220;+super.getName()+&#8221;\\nColor : &#8220;+super.getColor()+&#8221;\\nCapacity : &#8220;+super.getCC()+&#8221;\\nSpeed : &#8220;+super.getSpeed()+&#8221;\\nPrice : &#8220;+getPrice1()+&#8221;\\nManufacturer Discount : &#8220;+getDiscount()+&#8221;\\nSports Bike price is &#8220;+super.getPrice();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">class Scooter extends Bike{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private int discount;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private double price1;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">private int weight;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public Scooter(String name, String colour, Float cc, Integer speed, Double price, Integer weight, int discount) {<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setName(name);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setColor(color);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setCC(cc);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setSpeed(speed);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.price1=price;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.discount=discount;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; this.weight=weight;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setPrice(price-discount);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; super.setWeight(weight);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public int getDiscount(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return discount;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public double getPrice1(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return price1;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public int getWeight(){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return weight;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public String toString()<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; return &#8220;Name : &#8220;+super.getName()+&#8221;\\nColor : &#8220;+super.getColor()+&#8221;\\nCapacity : &#8220;+super.getCC()+&#8221;\\nSpeed : &#8220;+super.getSpeed()+&#8221;\\nPrice : &#8220;+getPrice1()+&#8221;\\nWeight : &#8220;+getWeight()+&#8221;\\nManufacturer Discount : &#8220;+getDiscount()+&#8221;\\nScooter price is &#8220;+super.getPrice();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">class Main{<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">public static void main(String args[]){<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; String name;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; String colour;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; float cc;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; int speed;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; double price;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; int manufacturerDiscount;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; int weight;<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; \/\/<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Enter the details of Sports Bike&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; Scanner scan=new Scanner(System.in);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Name of the bike:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; name=scan.next();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Color of the bike:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; color=scan.next();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Capacity(cc) of the bike:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; cc=scan.nextFloat();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Speed of the bike:&#8221;);<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Continue on TCS Aspire basic programming quiz questions and answers!<\/strong><\/h4>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; speed=scan.nextInt();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Price of the bike:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; price=scan.nextDouble();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Discount of the bike:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; manufacturerDiscount=scan.nextInt();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; Sportbike qwert=new Sportbike(name,color,cc,speed,price,manufacturerDiscount);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; \/\/<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Enter the details of Scooter&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Name of the Scooter&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; name=scan.next();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Color of the Scooter:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; color=scan.next();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Capacity(CC) of the Scooter:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; cc=scan.nextFloat();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Speed of the Scooter:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; speed=scan.nextInt();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Price of the Scooter:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; price=scan.nextDouble();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Discount of the scooter:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; manufacturerDiscount=scan.nextInt();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Weight of the scooter:&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; weight=scan.nextInt();<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; Scooter yuio =new Scooter(name,color,cc,speed,price,weight,manufacturerDiscount);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Sports Bike :&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(qwert.toString());<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&#8220;Scooter :&#8221;);<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(yuio.toString());<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p class=\"has-ast-global-color-4-background-color has-background\">}<\/p>\n\n\n\n<p><em>Looking for <a href=\"https:\/\/www.guvi.in\/blog\/all-about-tcs-xplore\/\" target=\"_blank\" rel=\"noreferrer noopener\">TCS Xplore <\/a>Python Coding questions: <a href=\"https:\/\/www.guvi.in\/blog\/tcs-xplore-python-coding-questions\/\" target=\"_blank\" rel=\"noreferrer noopener\">Top 9 TCS Xplore Python Coding Questions [DeCode with HCL GUVI]<\/a><\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>To Conclude<\/strong><\/h2>\n\n\n\n<p>We know, this series of important questions on <strong>TCS Aspire and TCS Xplore<\/strong> is getting interesting, and you crave more programs like these. Don&#8217;t you? Check our <a href=\"https:\/\/www.guvi.in\/code-kata\/\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/code-kata\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>CODEKATA <\/strong><\/a>&amp; <a href=\"https:\/\/www.guvi.in\/webkata\/\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/webkata\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>WEBKATA <\/strong><\/a>platforms for more interesting practice programs.<\/p>\n\n\n\n<p><strong>Have a query? Drop your queries, suggestions, and thoughts in the comment section below! Keep Learning!<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-3-color\">Related Topics<\/mark><\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/www.guvi.in\/blog\/amazon-data-scientist-interview-questions\/\" target=\"_blank\" data-type=\"post\" data-id=\"11928\" rel=\"noreferrer noopener\"><strong>Top 100 Important Amazon Data Scientist Interview Questions<\/strong><\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.guvi.in\/blog\/postman-interview-questions\/\" target=\"_blank\" data-type=\"post\" data-id=\"11799\" rel=\"noreferrer noopener\"><strong>Top Postman Interview Questions<\/strong><\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.guvi.in\/blog\/top-5-cred-interview-questions-for-sde-role\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/blog\/top-5-cred-interview-questions-for-sde-role\/\" rel=\"noreferrer noopener\"><strong>Top 5 CRED Interview Questions<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Got a call letter from TCS? Then you might be looking for TCS Aspire Basic Programming Quiz Questions and Answers. Don&#8217;t you? Because Aspire is&nbsp;a mandatory learning program for all recruits of IT and EIS. TCS Aspire is an initial online interactive learning program. TCS Aspire is meant for everyone, especially for someone who is [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":12119,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[719,13],"tags":[],"views":"5743","authorinfo":{"name":"Archana","url":"https:\/\/www.guvi.in\/blog\/author\/archana\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/08\/5.-TCS-Aspire-Basic-Programming-Quiz-Answers-300x157.png","jetpack_featured_media_url":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/08\/5.-TCS-Aspire-Basic-Programming-Quiz-Answers.png","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/12010"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=12010"}],"version-history":[{"count":22,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/12010\/revisions"}],"predecessor-version":[{"id":89727,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/12010\/revisions\/89727"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/12119"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=12010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=12010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=12010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}