Skip to main content

Posts

May 9 tcs cpa java coding questions:Antenna problem.

 QUESTION: create a class Antenna with below attributes. antennaid=int antennaName=String projectLead=String antennaVSWR=double the above attribute should be private ,write getter and setter and parametrized constructor as well. create class MyClass with main method. implement two static methods searchAntennaByName and sortAntennaByVSWR in MyClass class. searchAntennaByName :   This method will take an array of Antenna objects and the string value as input parameter.The method will find out Antenna name(String parameter passed) .it will return Antennaid if found.if there is no Antenna that matches then the method will return zero. the main method should print the antennaid,if the returned value is not 0.if the returned value is 0 then print,"There is no antenna with the given parameter". sortAntennaByVSWR: This method will take an array of Antenna Objects and a double value as input. this method will return an array of Antenna objects sorted in ascending orderof their antenna

TCS XPLORE CAMERA PROCTORED ASSESSMENT EXAM JAVA CODING SOLUTION 10 MAY,2021. FOOTWEAR PROBLEM.

 create a class Footwear which consists of the below attributes.   footwearId=int   footwearName=String   footwearType=String   price =int the above attributes should be private. write getter and setter and parametrised constructor as required. create the class footwearProgrammm with the main method. implement the 2 static methods.getCountByType and getSecondHighestPriceByBrand in the Solution class. getCountByType method:    this method will take two input parameters. array of the Footwear objects and string parameter footwear type. this method will return the count of the footwears from array of the footwear objects for the given type of footwear. if no footwear with the given footwear type is found in the array of footwear abjects,then the method should return 0. getSecondHighestPriceByBrand method:   this method will take 2 input parameters-array of footwear objects and string parameter inputFootwearName.the method will return the second highest footwear objects based on the price

tcs xplore java hands on | java iterations hands on 2 | factorial of 5 user entered numbers

 java iteration hands on 2. question: write the program to read the 5 numbers and find the factorial of each. input: 2 3 4 5 6 output: 2 6 24 120 720.     answer:   import java.util.Scanner; public class factorial { public static void main(String[] args) { Scanner sc= new Scanner(System. in ); int arr[]= new int [ 5 ]; int arrforfact[]= new int [ 5 ]; for ( int i = 0 ; i < 5 ; i++) { int num=sc.nextInt(); arr[i]=num; } for ( int i = 0 ; i < 5 ; i++) { int numm=arr[i]; int temp= 1 ; for ( int j = 1 ; j <=numm ; j++) { temp=temp*j; } arrforfact[i]=temp; } for ( int i = 0 ; i < 5 ; i++) { System. out .println(arrforfact[i]); } } }    

Vowels_Consonants_Count

 Problem Statement Write a Java program to count both vowels and consonants in a given string Conditions Only alphabets should be considered for counting Input Hello World! Output Vowels count - 3 Consonants count - 7 Explanation     The vowels in the given string are e,o and o and so the vowels count is 3. Likewise, the consonants in the given string are h,l,l,w,r,l and d and so the count is 7.

Unique_Characters

  Problem Statement Write a Java program to print the unique characters present in the given string in the same sequence as they appear(the first occurrence) in the input. Condition All the characters should be in lowercase only. Input xperience Output xperinc