Basics Of Core Java

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Learningcorejava
L
Learningcorejava
Community Contributor
Quizzes Created: 2 | Total Attempts: 317
Questions: 50 | Attempts: 216

SettingsSettingsSettings
Core Java Quizzes & Trivia

Simple Quiz based on basics of Core Java covering almost all important aspects of programming language.
Make sure to come out with flying colors.
Passing: 80%
Time: 30 Minutes
www. Java-interviewer. Blogspot. Com


Questions and Answers
  • 1. 

    You would use Java because?

    • A.

      It is platform independant

    • B.

      It follows OOPs

    • C.

      It is Open Source

    Correct Answer(s)
    A. It is platform independant
    B. It follows OOPs
    C. It is Open Source
    Explanation
    The reason why you would use Java is because it is platform independent, meaning that it can run on any operating system. Additionally, Java follows the principles of Object-Oriented Programming (OOPs), which allows for modular and reusable code. Lastly, Java is an open-source language, which means that it is freely available and can be modified and distributed by anyone.

    Rate this question:

  • 2. 

    What does WORA stands for?

    • A.

      Wear Ornaments, Run Anywhere

    • B.

      Write Once, Run Anywhere

    • C.

      Write Once, Read Again

    • D.

      Write Only, Read Only

    Correct Answer
    B. Write Once, Run Anywhere
    Explanation
    WORA stands for Write Once, Run Anywhere. This term is commonly used in software development to describe the ability of a program to be written only once and then run on any platform or operating system without the need for additional modifications or adaptations. This concept is often associated with the Java programming language, which allows developers to create platform-independent applications that can be executed on various devices and operating systems.

    Rate this question:

  • 3. 

    Which of the following access restriction is more restricted than others?

    • A.

      Public

    • B.

      Private

    • C.

      Protected

    • D.

      Default

    Correct Answer
    B. Private
    Explanation
    The access restriction "private" is more restricted than the others because it limits access to only within the same class. This means that private members or methods cannot be accessed or modified by any other classes, even subclasses or classes in the same package. It provides the highest level of encapsulation and data hiding, ensuring that sensitive information is not accessible to other parts of the program.

    Rate this question:

  • 4. 

    Java is pass by value. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    In Java, variables are passed by value. This means that when a method is called and a parameter is passed, a new copy of the variable is created and any changes made to the parameter within the method do not affect the original variable. Therefore, the correct answer is true.

    Rate this question:

  • 5. 

    Which of the following is NOT an example of RuntimeException

    • A.

      NullPointerException

    • B.

      NumberFormatException

    • C.

      ArrayIndexOutOfBoundException

    • D.

      FileNotFoundException

    Correct Answer
    D. FileNotFoundException
    Explanation
    The FileNotFoundException is not an example of a RuntimeException because it is a checked exception. Checked exceptions must be declared in a method's signature or handled explicitly with a try-catch block, whereas RuntimeExceptions do not need to be declared or caught.

    Rate this question:

  • 6. 

    Can I restart a thread after it's lifecycle is complete?

    • A.

      Yes, You can

    • B.

      No, You can not. It will give you IllegalThreadStateException if you try to restart a dead thread.

    Correct Answer
    B. No, You can not. It will give you IllegalThreadStateException if you try to restart a dead thread.
    Explanation
    Once a thread's lifecycle is complete, it cannot be restarted. If you try to restart a dead thread, it will throw an IllegalThreadStateException. This exception is thrown to indicate that a thread is not in an appropriate state for the requested operation. Therefore, the correct answer is that you cannot restart a thread after its lifecycle is complete.

    Rate this question:

  • 7. 

    If Class Employee extends Class Person, Which of the below statements can I write below statement using generics? 

    • A.

      List< Person > list = new ArrayList< Person >();

    • B.

      List< Employee > list = new List< Employee >();

    • C.

      List< Employee > list = new ArrayList< Person >();

    • D.

      List< Person > list = new ArrayList< Employee >();

    Correct Answer
    A. List< Person > list = new ArrayList< Person >();
    Explanation
    The correct answer is "List< Person > list = new ArrayList< Person >();". This statement is correct because it creates a new ArrayList object that can store objects of type Person, and assigns it to a variable of type List. This is possible because the class Employee extends the class Person, so an ArrayList can also store objects of type Employee. The other statements are incorrect because they either try to assign an ArrayList to a variable of type List, which is not allowed, or they try to assign an ArrayList to a variable of type List, which is also not allowed.

    Rate this question:

  • 8. 

    Generics are used for Compile Time Type Safety. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Generics are used in programming languages, such as Java, to provide compile-time type safety. This means that generics allow the programmer to specify the type of objects that a particular data structure or method can work with, and the compiler checks that the correct types are used at compile time. This helps to catch type errors early on, preventing runtime errors and improving the overall reliability and robustness of the code. Therefore, the statement that generics are used for compile-time type safety is true.

    Rate this question:

  • 9. 

    How to iterate over a List?List<String> list = new ArrayList<String> ();  

    • A.

      For (String s : list) {....}

    • B.

      Iterator iterator = list.iterator(); while(iterator.hasNext()){ System.Out.println(iterator.next()); }

    Correct Answer(s)
    A. For (String s : list) {....}
    B. Iterator iterator = list.iterator(); while(iterator.hasNext()){ System.Out.println(iterator.next()); }
    Explanation
    The correct answer is a combination of two methods to iterate over a List. The first method is using a for-each loop, which allows us to iterate over each element in the list and perform some action. The second method is using an Iterator, which provides a way to access the elements of a collection one by one. The Iterator hasNext() method checks if there are more elements in the list, and the next() method returns the next element in the list. By using both methods, we can ensure that we cover all elements in the List and perform the desired actions.

    Rate this question:

  • 10. 

    Which of the following is NOT used for iteration purposes?

    • A.

      For

    • B.

      While

    • C.

      Do while

    • D.

      Switch

    Correct Answer
    D. Switch
    Explanation
    The switch statement is not used for iteration purposes. It is used for decision-making and branching based on different cases or values. The for, while, and do while loops are used for iteration, allowing a set of statements to be repeated multiple times based on a condition.

    Rate this question:

  • 11. 

    Which keyword is used to instantiate an object of a class?

    • A.

      Final

    • B.

      New

    • C.

      Volatile

    • D.

      Super

    Correct Answer
    B. New
    Explanation
    The keyword "new" is used to instantiate an object of a class. When we use the "new" keyword followed by the class name and parentheses, it allocates memory for the object and calls the constructor of the class to initialize the object. This allows us to create instances of a class and use its methods and variables.

    Rate this question:

  • 12. 

    Objects and instance variables are stored on Heap while method variables are stored on a stack. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Objects and instance variables are indeed stored on the heap. The heap is a region of memory that is used for dynamic memory allocation. It is where objects and their instance variables are allocated and stored. On the other hand, method variables, also known as local variables, are stored on the stack. The stack is a region of memory that is used for storing local variables and function call information. Therefore, the statement "Objects and instance variables are stored on Heap while method variables are stored on a stack" is true.

    Rate this question:

  • 13. 

    What are differences between Hashtable and HashMap?

    • A.

      Hashtable is synchronised while HashMap is not

    • B.

      HashMap is faster than Hashtable

    Correct Answer(s)
    A. Hashtable is synchronised while HashMap is not
    B. HashMap is faster than Hashtable
    Explanation
    The given answer correctly explains two differences between Hashtable and HashMap. It states that Hashtable is synchronized, meaning that it is thread-safe and multiple threads can access it simultaneously without any issues. On the other hand, HashMap is not synchronized, which means it is not thread-safe and can lead to data inconsistency if accessed by multiple threads concurrently. Additionally, the answer mentions that HashMap is faster than Hashtable, implying that HashMap has better performance in terms of insertion, deletion, and retrieval of elements.

    Rate this question:

  • 14. 

    Which of the following is not a method of Object class?

    • A.

      Equals

    • B.

      Hashcode

    • C.

      ToString

    • D.

      Clone

    • E.

      Wait

    • F.

      Run

    Correct Answer
    F. Run
    Explanation
    The method "run" is not a method of the Object class. The Object class in Java provides a set of common methods that are inherited by all other classes, such as equals, hashCode, toString, and clone. However, "run" is not one of these common methods. It is typically used in the context of multithreading, where a class implements the Runnable interface and defines its own run method to specify the code that will be executed in a separate thread.

    Rate this question:

  • 15. 

    Object is the parent class of every class. True or False?

    • A.

      False

    • B.

      True

    Correct Answer
    B. True
    Explanation
    The given statement is true. In object-oriented programming, the object is the parent class of every class. This means that every class in a program is derived from the object class. The object class provides the basic functionality and features that are common to all objects in the program. Therefore, the statement "Object is the parent class of every class" is correct.

    Rate this question:

  • 16. 

    What is a marker interface?

    • A.

      An interface who do not have any methods

    • B.

      JVM gives special treatment to such interfaces

    • C.

      Clonable, Serializable are some examples of marker interface

    Correct Answer(s)
    A. An interface who do not have any methods
    B. JVM gives special treatment to such interfaces
    C. Clonable, Serializable are some examples of marker interface
    Explanation
    A marker interface is an interface that does not have any methods. These interfaces are given special treatment by the JVM. Clonable and Serializable are examples of marker interfaces.

    Rate this question:

  • 17. 

    What is the difference between calling run method and calling start method on a thread?

    • A.

      There is no difference

    • B.

      Run method will just execute the code in main method while start method will actually execute the code in new thread

    • C.

      Start method will just execute the code in main method while run method will actually execute the code in new thread

    Correct Answer
    B. Run method will just execute the code in main method while start method will actually execute the code in new thread
    Explanation
    The correct answer is that calling the run method will just execute the code in the main method, while calling the start method will actually execute the code in a new thread.

    Rate this question:

  • 18. 

    How to create a thread in Java?

    • A.

      By extending Thread class

    • B.

      By implementing Runnable interface

    • C.

      By implementing Threadable interface

    Correct Answer(s)
    A. By extending Thread class
    B. By implementing Runnable interface
    Explanation
    In Java, there are two ways to create a thread. One way is by extending the Thread class, where the class that needs to be executed as a thread extends the Thread class and overrides the run() method. The other way is by implementing the Runnable interface, where the class that needs to be executed as a thread implements the Runnable interface and overrides the run() method. Both approaches allow the class to be executed concurrently as a separate thread.

    Rate this question:

  • 19. 

    Which of the JCF API will you use if you do want sorted non duplicate elements?

    • A.

      TreeSet

    • B.

      TreeMap

    • C.

      LinkedList

    • D.

      LinkedHashSet

    Correct Answer
    A. TreeSet
    Explanation
    The correct answer is TreeSet. TreeSet is a class in the JCF API that implements the SortedSet interface, which means it automatically sorts the elements in ascending order. Additionally, TreeSet does not allow duplicate elements, so it is suitable for storing sorted non-duplicate elements. TreeMap is used to store key-value pairs in sorted order, LinkedList is a doubly linked list implementation, and LinkedHashSet is a hash table implementation that maintains the insertion order.

    Rate this question:

  • 20. 

    Which of the following is an example of Ordered List?

    • A.

      LinkedList

    • B.

      ArrayList

    • C.

      Vector

    • D.

      HashSet

    Correct Answer
    A. LinkedList
    Explanation
    A LinkedList is an example of an Ordered List because it maintains the order of elements as they are added. Elements are linked together using pointers, allowing for efficient insertion and deletion operations. In contrast, ArrayList and Vector are examples of Dynamic Arrays, which do not necessarily maintain the order of elements. HashSet is an example of an Unordered List, as it does not maintain any specific order of elements.

    Rate this question:

  • 21. 

    Set does not allow duplicate elements. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Sets are data structures in programming that do not allow duplicate elements. Each element in a set is unique, and any attempt to add a duplicate element will be ignored. Therefore, the statement "Set does not allow duplicate elements" is true.

    Rate this question:

  • 22. 

    Which one is faster?

    • A.

      Vector

    • B.

      ArrayList

    Correct Answer
    B. ArrayList
    Explanation
    ArrayList is faster than Vector because ArrayList is not synchronized, which means it is not thread-safe. This allows for faster execution since there is no overhead of acquiring and releasing locks. On the other hand, Vector is synchronized, meaning it is thread-safe, but this synchronization adds extra overhead and can slow down the performance. Therefore, in scenarios where thread safety is not a concern, ArrayList is generally preferred for its faster execution.

    Rate this question:

  • 23. 

    LinkedList implements which interfaces?

    • A.

      List

    • B.

      Queue

    • C.

      Map

    • D.

      Set

    Correct Answer(s)
    A. List
    B. Queue
    Explanation
    LinkedList in Java implements the List and Queue interfaces. The List interface provides an ordered collection of elements with the ability to add, remove, and access elements by their index. The Queue interface provides methods for adding elements to the end of the list and removing elements from the beginning of the list, making it suitable for implementing a queue data structure. Therefore, LinkedList implements both List and Queue interfaces.

    Rate this question:

  • 24. 

    Which of the following interfaces extend Collection interface?

    • A.

      List

    • B.

      Set

    • C.

      Map

    • D.

      Queue

    Correct Answer(s)
    A. List
    B. Set
    D. Queue
    Explanation
    The correct answer is List, Set, and Queue. These three interfaces extend the Collection interface in Java. The Collection interface is the root interface in the Java Collections Framework and provides the basic functionality for working with collections of objects. List is an ordered collection that allows duplicate elements, Set is an unordered collection that does not allow duplicate elements, and Queue is a collection that orders the elements in a specific way and allows for efficient insertion and removal. Map, on the other hand, is not an interface that extends Collection. It is a separate interface that represents a mapping between keys and values.

    Rate this question:

  • 25. 

    What would be the return value of below method?public static int getValue(){ int i = 10; if (i >= 5){ return 100; }else if(i <= 11){ return 11; }else{ return 0; } }

    • A.

      100

    • B.

      11

    • C.

      0

    Correct Answer
    A. 100
    Explanation
    The return value of the method would be 100. This is because the condition "i >= 5" is true, so the first return statement is executed and the value 100 is returned. The other conditions are not evaluated since the first condition is true.

    Rate this question:

  • 26. 

    HashMap is not a part of Collection hierarchy. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The statement is true. HashMap is not a part of the Collection hierarchy in Java. The Collection interface is the root interface in the Collection hierarchy, and it is implemented by classes such as ArrayList, LinkedList, HashSet, etc. However, HashMap is not a direct implementation of the Collection interface. Instead, it is a part of the Map interface hierarchy, along with other classes such as TreeMap and LinkedHashMap.

    Rate this question:

  • 27. 

    An interface can extend unlimited number of interfaces.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    An interface in programming is a contract that specifies a set of methods that a class implementing the interface must provide. In Java, an interface can indeed extend any number of other interfaces. This allows for the inheritance of method signatures from multiple interfaces, enabling more flexibility and code reuse in object-oriented programming. Therefore, the given statement is true.

    Rate this question:

  • 28. 

    A class can extend how many classes?

    • A.

      0 to 1

    • B.

      0 to many

    • C.

      Unlimited

    Correct Answer
    A. 0 to 1
    Explanation
    A class in object-oriented programming can extend at most one class. This is because multiple inheritance, where a class can inherit from multiple classes, is not supported in all programming languages. However, a class can implement multiple interfaces, which allows it to inherit behavior from multiple sources. Therefore, the correct answer is 0 to 1.

    Rate this question:

  • 29. 

    Which is a correct definition for a interface?

    • A.

      Public abstract interface Talkable{}

    • B.

      Interface Talkable{}

    • C.

      Private final interface Talkable{}

    • D.

      Public interface Talkable{}

    Correct Answer(s)
    A. Public abstract interface Talkable{}
    B. Interface Talkable{}
    D. Public interface Talkable{}
    Explanation
    The correct definition for an interface is a public abstract interface Talkable{} or public interface Talkable{}. This is because an interface is a blueprint for a class and is declared using the "interface" keyword. It can have abstract methods that are implemented by classes that implement the interface. The "public" keyword indicates that the interface can be accessed from other classes, and the "abstract" keyword indicates that the interface cannot be instantiated. The other options, private final interface Talkable{} and interface Talkable{}, are incorrect because interfaces cannot be declared as private or final.

    Rate this question:

  • 30. 

    Garbage Collection works in a daemon thread. Daemon thread is a low priority thread. True or False.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Garbage Collection in Java works in a daemon thread. A daemon thread is a low priority thread that runs in the background and does not prevent the JVM from exiting if all other non-daemon threads have finished their execution. Since garbage collection is an ongoing process that automatically manages memory by reclaiming unused objects, it makes sense for it to run in a daemon thread to avoid interfering with the main execution of the program. Therefore, the statement is true.

    Rate this question:

  • 31. 

    How can you invoke garbage collection?

    • A.

      System.gc();

    • B.

      Runtime.getRuntime().gc();

    • C.

      System.garbageCollection()

    • D.

      This.gc()

    Correct Answer(s)
    A. System.gc();
    B. Runtime.getRuntime().gc();
    Explanation
    The correct answers for invoking garbage collection in Java are System.gc(); and Runtime.getRuntime().gc();. These methods are used to suggest the JVM to run the garbage collector in order to free up memory by removing unreferenced objects. The other options, System.garbageCollection() and this.gc(), are not valid methods for invoking garbage collection in Java.

    Rate this question:

  • 32. 

    Which of the following objects are eligible for Garbage Collection?

    • A.

      Whose values are null

    • B.

      Which are not referenced further

    • C.

      Isolated objects

    Correct Answer(s)
    A. Whose values are null
    B. Which are not referenced further
    C. Isolated objects
    Explanation
    Objects that have null values, objects that are not referenced further, and isolated objects are eligible for garbage collection. When an object's value is null, it means that it does not hold any useful data and can be safely removed. Objects that are not referenced further means that there are no variables or references pointing to them, indicating that they are no longer needed. Isolated objects are objects that are not reachable from the root of the object graph, making them unreachable and eligible for garbage collection.

    Rate this question:

  • 33. 

    Which of the following is a class?

    • A.

      Throwable

    • B.

      Runnable

    • C.

      Callable

    • D.

      Collection

    Correct Answer
    A. Throwable
    Explanation
    The correct answer is Throwable because Throwable is a class in Java. It is the superclass of all errors and exceptions in the Java language. It provides methods and fields for handling and propagating errors and exceptions.

    Rate this question:

  • 34. 

    What would be the return value of following method:public static int getValue(){ try{ return 1; }finally{ return 2; } }

    • A.

      1

    • B.

      2

    • C.

      1 and 2

    • D.

      Runtime Error

    Correct Answer
    B. 2
    Explanation
    The return value of the method would be 2. This is because the finally block is always executed, regardless of whether an exception is thrown or not. In this case, even though the try block returns 1, the finally block overrides it and returns 2.

    Rate this question:

  • 35. 

    Which of the following combinations of try-catch-finally are permitted?

    • A.

      Try-catch-finally

    • B.

      Try-catch

    • C.

      Try-multiple catch

    • D.

      Try-finally

    • E.

      Catch-finally

    • F.

      Try-multiple catch-finally

    Correct Answer(s)
    A. Try-catch-finally
    B. Try-catch
    C. Try-multiple catch
    D. Try-finally
    F. Try-multiple catch-finally
    Explanation
    All of the given combinations of try-catch-finally are permitted. The try-catch-finally combination is used to handle exceptions where the code in the try block is executed, and if an exception occurs, it is caught in the catch block. The finally block is always executed, whether an exception occurs or not. The try-catch combination is used to catch and handle a specific type of exception. The try-multiple catch combination is used to catch and handle multiple types of exceptions. The try-finally combination is used when there is no need to catch the exception, but some code needs to be executed before exiting the try block. The try-multiple catch-finally combination is used to catch and handle multiple types of exceptions, and execute some code before exiting the try block.

    Rate this question:

  • 36. 

    Finally block always executes. True or False?

    • A.

      True

    • B.

      True, except if System.exit() is called

    • C.

      False

    Correct Answer
    B. True, except if System.exit() is called
    Explanation
    The statement is true because the finally block in Java always executes, except in the case where System.exit() is called. The finally block is used to define a section of code that will be executed regardless of whether an exception is thrown or not. It is commonly used to release resources or perform clean-up operations. However, if System.exit() is called, it terminates the JVM and the finally block will not be executed.

    Rate this question:

  • 37. 

    What is the load factor of a hash map?

    • A.

      1

    • B.

      100

    • C.

      0.75

    • D.

      0.25

    Correct Answer
    C. 0.75
    Explanation
    The load factor of a hash map is a measure of how full the hash map is. It is calculated by dividing the current number of elements in the hash map by the total number of buckets in the hash map. A load factor of 0.75 means that the hash map is 75% full. A higher load factor indicates a higher chance of collisions, while a lower load factor indicates a lower chance of collisions but potentially wasted memory.

    Rate this question:

  • 38. 

    Which of the following statements are correct?

    • A.

      JVM stands for Java Virtual Machine

    • B.

      JRE stands for Java Runtime Environment

    • C.

      JDK stands for Java Development Kit

    • D.

      JCF stands for Java Collection Framework

    Correct Answer(s)
    A. JVM stands for Java Virtual Machine
    B. JRE stands for Java Runtime Environment
    C. JDK stands for Java Development Kit
    D. JCF stands for Java Collection Framework
    Explanation
    The given answer is correct. JVM stands for Java Virtual Machine, which is a virtual machine that executes Java bytecode. JRE stands for Java Runtime Environment, which includes the JVM along with libraries and other components necessary for running Java applications. JDK stands for Java Development Kit, which is a software development environment that includes tools for developing, debugging, and compiling Java applications. JCF stands for Java Collection Framework, which is a set of classes and interfaces in Java that implement commonly used data structures and algorithms for handling collections of objects.

    Rate this question:

  • 39. 

    Which of the following is INCORRECT statement?

    • A.

      Package (if any) statement must be the first statement of your source file

    • B.

      You can import zero to multiple classes to your source file using import statements

    • C.

      For multi-line comments, /* code to comment */ can be used

    • D.

      Java is platform dependent because of JVM

    Correct Answer
    D. Java is platform dependent because of JVM
    Explanation
    The statement "Java is platform dependent because of JVM" is incorrect. Java is actually considered platform-independent because of the Java Virtual Machine (JVM), which allows Java programs to run on any platform that has a JVM installed. The JVM acts as an interpreter that translates Java bytecode into machine code that can be executed by the underlying operating system. This allows Java programs to be written once and run anywhere, making Java a popular choice for cross-platform development.

    Rate this question:

  • 40. 

    Constructors are special methods whose name is equal to name of class. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Constructors are special methods in a class that have the same name as the class itself. They are used to initialize the objects of a class. Hence, the given statement "Constructors are special methods whose name is equal to the name of the class" is true.

    Rate this question:

  • 41. 

    If any one of the method of a class is abstract, you must mark the whole class abstract. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    If any one of the methods of a class is abstract, it means that the class is designed to be inherited and the abstract method must be implemented by its subclasses. Therefore, it is necessary to mark the whole class as abstract in order to prevent it from being instantiated directly. This ensures that the class is used only for inheritance purposes and cannot be instantiated on its own. Hence, the statement "If any one of the method of a class is abstract, you must mark the whole class abstract" is true.

    Rate this question:

  • 42. 

    If none of the method of a class is abstract, you can still mark the class as abstract. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Yes, you can still mark a class as abstract even if none of its methods are abstract. This is because the abstract keyword is used to indicate that a class cannot be instantiated and is meant to be subclassed. It serves as a way to provide a base implementation for subclasses while allowing them to override certain methods if needed. So, even if all the methods in a class have a concrete implementation, the class can still be marked as abstract to enforce the restriction that it cannot be instantiated directly.

    Rate this question:

  • 43. 

    Which keyword will you use if you do not want to provide implementation of a method?

    • A.

      Abstract

    • B.

      Final

    • C.

      Null

    • D.

      Volatile

    Correct Answer
    A. Abstract
    Explanation
    The keyword "abstract" is used when you do not want to provide implementation of a method. By using the "abstract" keyword, you are indicating that the method is incomplete and must be implemented by any class that extends the abstract class or implements the abstract method. This allows for the creation of abstract classes and methods that provide a common structure or behavior, but require subclasses to provide the specific implementation details.

    Rate this question:

  • 44. 

    Which of the following is NOT a Java Keyword?

    • A.

      Null

    • B.

      Volatile

    • C.

      Transient

    • D.

      Assert

    Correct Answer
    A. Null
    Explanation
    The keyword "null" is not a Java keyword. It is a special literal that represents the absence of a value or a null reference. Java keywords are reserved words that have a specific meaning and cannot be used as identifiers in the code. The keywords "volatile," "transient," and "assert" are all valid Java keywords used for different purposes in the language.

    Rate this question:

  • 45. 

    Which keyword can be applied to both methods and variables to make them available per Class instead of per Instance?

    • A.

      Final

    • B.

      Abstract

    • C.

      Static

    • D.

      Public

    Correct Answer
    C. Static
    Explanation
    The keyword "static" can be applied to both methods and variables to make them available per Class instead of per Instance. When a method or variable is declared as static, it means that it belongs to the class itself rather than any specific instance of the class. This means that the method or variable can be accessed and used without creating an instance of the class. It is commonly used for utility methods or variables that are shared among all instances of the class.

    Rate this question:

  • 46. 

    Which of the following statements are true?

    • A.

      A Class is a template that describes the kinds of state and behavior that objects of its type support

    • B.

      Object is an instance of a class

    • C.

      All methods of an interface are implicitly public and abstract

    • D.

      Constructors can not be overloaded

    Correct Answer(s)
    A. A Class is a template that describes the kinds of state and behavior that objects of its type support
    B. Object is an instance of a class
    C. All methods of an interface are implicitly public and abstract
    Explanation
    A class is a template that describes the kinds of state and behavior that objects of its type support. This means that a class defines the properties (state) and actions (behavior) that objects of that class can have. An object, on the other hand, is an instance of a class. It is created based on the template provided by the class and can have its own unique state and behavior. Additionally, all methods of an interface are implicitly public and abstract. This means that they are accessible from other classes and must be implemented by any class that implements that interface. Constructors, however, can be overloaded, allowing for different ways to initialize objects of a class.

    Rate this question:

  • 47. 

    OOPs stands for Object Oriented Programming system. True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    OOPs stands for Object Oriented Programming system. This is a true statement. Object Oriented Programming (OOP) is a programming paradigm that organizes data and behaviors into reusable structures called objects. It allows for modular and efficient code development by emphasizing the concepts of encapsulation, inheritance, and polymorphism.

    Rate this question:

  • 48. 

    What are OOPs principals?

    • A.

      Inheritance

    • B.

      Poly Morphism

    • C.

      Encapsulation

    • D.

      Abstraction

    Correct Answer(s)
    A. Inheritance
    B. Poly Morphism
    C. Encapsulation
    D. Abstraction
    Explanation
    The given answer lists the four main principles of Object-Oriented Programming (OOP). Inheritance allows objects to inherit properties and behaviors from parent classes. Polymorphism allows objects to take on multiple forms and have different behaviors based on their context. Encapsulation refers to the bundling of data and methods within a class, hiding the internal implementation details. Abstraction focuses on simplifying complex systems by breaking them down into smaller, more manageable parts. These principles are fundamental in OOP and help in creating modular, reusable, and maintainable code.

    Rate this question:

  • 49. 

    Java is platform dependent. True or False?

    • A.

      False

    • B.

      True

    Correct Answer
    A. False
    Explanation
    Java is actually platform independent. This means that Java programs can run on any operating system or platform as long as it has a Java Virtual Machine (JVM) installed. The JVM acts as an intermediary between the Java program and the underlying hardware and operating system. This allows Java programs to be written once and run anywhere, making Java a popular choice for developing cross-platform applications.

    Rate this question:

  • 50. 

    Java is open source, True or False?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Java is indeed open source. Open source refers to a software that is freely available for users to view, modify, and distribute. Java is open source since its source code is accessible to the public and can be modified and distributed under the terms of the GNU General Public License (GPL). This allows developers to contribute to the improvement and customization of Java, making it a widely used and versatile programming language.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 21, 2014
    Quiz Created by
    Learningcorejava
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.