Skip to main content

TCS Xplore 2023 - JAVA MCQ question for best practice ( iON Proctored Assessment )

           Multiple Choice Question ( JAVA )


   ---------------------->>>>   Click Here :Subscribe to click  <<<<<--------------------------

PART - 01 

Q1 . What is size of float and double ?

        a.  32 and 64                      b. 32 and 32 

        c.  64 and 64                      d. 64 and 32 

Ans : 32 and 64 


Q2 .  What will be the output ? 

          short x=10;

          x*=5;

          System.out.println(x);

        a.  50                                b. 10

        c.  No output                    d. Compilation Error

Ans : Compilation Error


Q3.  find the error in which line ? 

        class A{

            final a;

            System.out.println(a);

            }

        a.  Line 1                           b. Line 2

        c.  Line 3                           d. No Error

Ans : Line 2


Q4.  Find the length of String ?

        a. using string.length()

        b. using string.length

Ans : a 


Q5.  Find the output ?

class A{

          .........

        }

       class Solution{

            Box box[]={b1,b2,b3,b4,b5};

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

                System.out.println(box[i]);

           }

       }

        a.    No Error                               b. error

        c.  print all array object               d. none of these 


Q6.  Objects includes ?

        a.  Attributes                           b. both

        c.  Behaviour                      d. none

Ans : c


Q7.   String str="I like JAVA";

         System.out.println(str.length());

        a. 11                          b. 10

        c.  9                           d. 3

Ans : a


Q8.  What is the extension of java file ?

Ans : .java


---------------------->>>>   Click Here :Subscribe to click  <<<<<--------------------------

PART - 02



---------------------->>>>   Click Here :Subscribe to click  <<<<<--------------------------


Q9.  Which of this is Super class of every class ?

        a.  String  class                    b. Object class 

        c.  Abstract class                  d. ArrayList class

Ans : b


Q10.  Which modifier is used to prevent any method or attribute to be not visible to external classes ? 

        a. private                           b. protected

        c.  public                           d. default

Ans : a


Q11.  All the classes can be simultaneously imported by which wildcard ? 

Ans : *


Q12.   Which of the following is the correct declaration of array of size 10 ?

        a.  int arr[10];

        b. int arr[10]=new int[10];

        c.  int arr[]=new int[10];

        d. int arr[]={10 elements };

Ans : c and d


Q13. public class Solution{

public static void main(String[] args){ byte x = 127; x++; x++; System.out.print(x); } }

Ans : -127 (Range of byte data in java is -128 to 127. But the byte data type in java is cyclic in nature.)

Q14. Arrays in java are -

        a. object references                          b. primitive data type

        c.  objects                                        d. none

Ans : objects


Q15.  Identify what can directly access and change the value of the variable res.

                Package com.mypackage;

                Public class Solution{

                           Private int res = 100;

                }

        a.  Any class                                                      b.  Solution class

        c.  Any class that extends Solution  class          d.  None

Ans :  b


Q16.     Identify the output of the following program.

            String str = “abcde”;

           System.out.println(str.substring(1, 3));

        a.  abc                                     b. bc

        c.  bcd                                    d. cd

Ans : b


Q17.    Identify the output of the following program.

          String str = “Hellow”;

         System.out.println(str.indexOf(t));

        a.  4                                     b. 3

        c.  6                                    d. -1

Ans : d ( because t is not present in the string )


Q18.   Identify the output of the following program.


Public class Test{

          Public static void main(String argos[]){

                   String str1 = “one”;

                   String str2 = “two”;

                   System.out.println(str1.concat(str2));

          }

}

Ans : onetwo


---------------------->>>>   Click Here :Subscribe to click  <<<<<--------------------------


Part : 03


---------------------->>>>   Click Here :Subscribe to click  <<<<<--------------------------

Q19.    How many objects will be created in the following?


String a = new String(“Interviewbit”);

String b = new String(“Interviewbit”);

Strinc c = “Interviewbit”;

String d = “Interviewbit”;

Ans : 3


Q20.   Find the output of the following code.

                   int ++a = 100;

                  System.out.println(++a);

Ans :  compilation error ( not a valid identifier )


Q21.  Find the output of the following code.


Public class Solution{

         Public static void main(String args[]){

                 Int i;

                 for(i = 1; i < 6; i++){ 

                     if(i > 3) continue;

                 }

                 System.out.println(i);

          }

}

Ans : 6


Q22.  Identify the infinite loop ?

        a.  for(;;)                                      b. for(int i=0;i<1;i--)

        c.  for(int i=0;;i++)                      d. All of the above

Ans : d


Q23.   Evaluate the following Java expression, if x=3, y=5, and z=10:

               ++z + y - y + z + x++

Ans :   25


Q24.    What are the types of memory allocated in memory in java?


a.   Heap memory

b.  Stack memory

c.  Both A and B

d.  None of these

Answer: C) Both A and B


Q25.  What is the entry point of a program in Java?


a.  main() method

b.  The first line of code

c.   Last line of code

d.   main class

Answer:  A) main() method


---------------------->>>>   Click Here :Subscribe to click  <<<<<--------------------------

---------------------- //     THANK YOU     // ------------------------------





Comments

Popular posts from this blog

Complete Strategy to clear TCS Xplore IPA in One Attempt Now ( 80+ Score )

  So hello Everyone , Here are the all Links from where you can Practice !  All the resources are searched from my best !  1. For KYT and Bizzskill  Link :- tcs Xplore course  2. Unix Operating system Link :-    a.  click here Link 1 b.  click here Link 2 c.  Click here Link 3   3. UI  Link :-  click here 4. SQL and Pl SQL Link : -  Click here Click here click here 5. Java MCQ  Link :-  click here click here click here 6. Java coding :-  Access the playlist on YouTube :-  click here to watch Access the blogs :-  click here All in one link :-   click here

TCS IPA previous year quistion ( 35 marks ) , Quistion , Input , output

 Problem Statement Video Link :    https://youtu.be/XCBvfJAo908 Create a class TravelAgencies with below attributes: regNo – int agencyName – String pakageType – String price – int flightFacility – boolean Write getters, setters for the above attributes . Create constructor which takes parameter in the above sequence. Create class Solution with main method. Implement two static methods – findAgencyWithHighestPackagePrice and agencyDetailsforGivenIdAndType in Solution class. findAgencyWithHighestPackagePrice method: This method will take array of TravelAgencies objects as an input parameter and return the highest package price from the given array of objects. agencyDetailsForGivenldAndType method: This method will take three input parameters -array of TravelAgencies objects, int parameter regNo and String parameter packageType. The method will return the TravelAgencies object based on below conditions. FlightFacility should be available. The input parameters(regNo and packageType) shoul

TCS IPA previous year problems solved [input + output ] in JAVA - (35 marks )

  Problem Statement :  Video Link :   Click Here Create a class AutonomousCar with the below attributes: carld – int brand – String   noOfTestsConducted – int noOfTestsPassed- int environment – String grade – String Write getters, setters for the above attributes . Create constructor which takes parameter in the above sequence except grade. Create class Solution with main method. Implement two static methods – findTestPassedByEnv and updateCarGrade in Solution class. findTestPassedByEnv method: This method will take two input parameters -array of AutonomousCar objects and string parameter environment. The method will return the sum of the noOfTestsPassed attribute from autonomousCar objects for the environment passed as parameter. If no autonomousCar with the given environment is present in the array of AutonomousCar objects, then the method should return 0. updateCarGrade method: This method will take a String parameter brand, along with the array of AutonomousCar objects. The method