Ctd Techs Java Assessment Test

30 Questions | Total Attempts: 222

SettingsSettingsSettings
Please wait...
Ctd Techs Java Assessment Test

.


Questions and Answers
  • 1. 
    What is the data type for the number 9.6352?
    • A. 

       float

    • B. 

      Double

    • C. 

      Float

    • D. 

      Double

  • 2. 
     What is the meaning of the return data type void?
    • A. 

      An empty memory space is returned so that the developers can utilize it.

    • B. 

      Void returns no data type.

    • C. 

      Void is not supported in Java.

    • D. 

       None of the above.

  • 3. 
     Java object oriented programming concepts is/are
    • A. 

      Encapsulation

    • B. 

      Inheritance

    • C. 

      Polymorphism

    • D. 

      All of the above.

  • 4. 
    False statement about final method in java
    • A. 

      Value of final variable cannot be changed once initialized.

    • B. 

      Final method is inherited but we cannot override it

    • C. 

      If you make a class final then you cannot extend the class

    • D. 

      Constructor can be declared as final.

  • 5. 
    Which method is called internally by Thread start() method?
    • A. 

      Execute()

    • B. 

      Run()

    • C. 

      Launch()

    • D. 

      Main()

  • 6. 
    A java interface can contain ————
    • A. 

      Public static Final Variables only

    • B. 

      Public Abstract methods

    • C. 

      Abstract methods(unimplemented) and implemented methods both

    • D. 

      Public static Final Variables and abstract methods both

  • 7. 
    Which is the correct way to inherit and implement the interface?  Consider and example, Interface is IAnimal and a class is Cat that wants to implement interface.
    • A. 

      Class Cat implements IAnimal{}

    • B. 

      Class Cat extends IAnimal{}

    • C. 

      Class Cat import IAnimal{}

    • D. 

      None is correct

  • 8. 
    Which of the following is true about methods in an interface in java?
    • A. 

      An interface can contain only abstract method.

    • B. 

      We can define a method in an interface

    • C. 

      Private and protected access modifiers can also be used to declare methods in interface

    • D. 

      None

  • 9. 
    Which is correct option about java interface?
    • A. 

      Interface is used to achieve multiple inheritance in java

    • B. 

      Object of an interface cannot be created.

    • C. 

      An interface can extend another interface.

    • D. 

      All of the above

  • 10. 
    Which is true statements about an interface in java?
    • A. 

      An interface can extend another interface

    • B. 

      We can create object of an interface in java

    • C. 

      An interface can have constructor

    • D. 

      None

  • 11. 
    Which polymorphism behavior do you see in below class? class Paint { // all methods have same name public void Color(int x) { } public void Color(int x, int y) { } public void Color(int x, int y, int z) { } }
    • A. 

      Method overloading

    • B. 

      Constructor overloading

    • C. 

      Method overriding

    • D. 

      Run time polymorphism

  • 12. 
    In below java code, whose “Car” will be called? class Father { public void car() { System.out.println("Father's Car"); } } class Son extends Father { public void car() { System.out.println("Son's Car"); } } public class Sample { public static void main(String[] args) { Son john = new Son(); john.car(); } }
    • A. 

      Father’s Car

    • B. 

      Son’s Car

    • C. 

      There is an ambiguity, so no one Car

    • D. 

      Compiler Error

  • 13. 
    Number of threads in below java program is public class ThreadExtended extends Thread { public void run() { System.out.println("\nThread is running now\n"); } public static void main(String[] args) { ThreadExtended threadE = new ThreadExtended(); threadE.start(); } }
    • A. 

      0

    • B. 

      1

    • C. 

      2

    • D. 

      3

  • 14. 
    Which thread will be executed first if two threads have same priority
    • A. 

      They will fall in starvation and none will be executed.

    • B. 

      Both will be executed simultaneously

    • C. 

      It depends upon operating system

    • D. 

      They will be executed on first come first serve basis

  • 15. 
    In what memory area, variable temp and variable card written in main () get stored? class CreditCard{ int num; } public class Bank { public static void main(String[] args) { int temp; CreditCard card; } }
    • A. 

      Heap, Heap

    • B. 

      Stack, stack

    • C. 

      Heap, Stack

    • D. 

      Stack, Heap

  • 16. 
    What exception can occur in the below java program if we access 5 element in the array that does not exist? public class TException { public static void main(String[] args) { try { int a[] = { 5, 10, 15, 20 }; System.out.println("Element :" + a[4]); } finally{} } }
    • A. 

      ArrayIndexOutOfBoundsException

    • B. 

      ArithmeticException

    • C. 

      NullPointerException

    • D. 

      None

  • 17. 
    Direct subclass of Throwable in Java
    • A. 

      Exception

    • B. 

      Error

    • C. 

      Both A & C

    • D. 

      None

  • 18. 
    Garbage collection in Java is
    • A. 

      Unused package in a program automatically gets deleted.

    • B. 

      Memory occupied by objects with no reference is automatically reclaimed for deletion.

    • C. 

      Java deletes all unused java files on the system.

    • D. 

      The JVM cleans output of Java program.

  • 19. 
    True statements about object of Insurance class is/are class Insurance{ int policyNumber; } public class Bank { public static void main(String[] args) { Insurance policy = new Insurance(); } }
    • A. 

      Class object will be garbage collected when it goes out of scope from main ()

    • B. 

      In the middle of main () function, class object can also be set for garbage collection by using statement “policy = NULL;”

    • C. 

      Both A & B are true

    • D. 

      None

  • 20. 
     ____________ provides run time environment for java byte code to be executed
    • A. 

      JDK

    • B. 

      JRE

    • C. 

      JVM

    • D. 

      JAVAC

  • 21. 
    What is output of this java program? public class MemoryJava { public static void main(String[] args) { decreaseNumberbyOne(2); } public static void decreaseNumberbyOne(int num){ if(num >= 0){ decreaseNumberbyOne(num -1); } System.out.println("Number:"+num); } }
    • A. 

      -1,0,1,2

    • B. 

      2,1,0,-1

    • C. 

      Stack overflow

    • D. 

      No output

  • 22. 
    __________ can be used to control the order of certain data structure and collection of objects too.
    • A. 

      Serial Comparators.

    • B. 

      Natural Comparators.

    • C. 

      Comparators.

    • D. 

      All of above.

  • 23. 
    After the following code fragment, what is the value in fname? String str; int fname; str = “Foolish boy.”; fname = str.indexOf(“fool”);
    • A. 

      0

    • B. 

      2

    • C. 

      -1

    • D. 

      4

  • 24. 
    Given the following code snippet; int salaries[]; int index = 0; salaries = new int salaries[4]; while (index < 4) { salaries[index] =  10000; index++; } What is the value of salaries[3]?
    • A. 

      40000

    • B. 

      50000

    • C. 

      15000

    • D. 

      10000

  • 25. 
    What is the value of number after the following code fragment execution? int number  = 0; int number2 = 12; while (number < number2) { number = number + 1; }
    • A. 

      5

    • B. 

      12

    • C. 

      21

    • D. 

      13

Back to Top Back to top