Syit Core Java 2019

Approved & Edited by ProProfs Editorial Team
At ProProfs Quizzes, our dedicated in-house team of experts takes pride in their work. With a sharp eye for detail, they meticulously review each quiz. This ensures that every quiz, taken by over 100 million users, meets our standards of accuracy, clarity, and engagement.
Learn about Our Editorial Process
| Written by Merina95varghese
M
Merina95varghese
Community Contributor
Quizzes Created: 3 | Total Attempts: 573
Questions: 35 | Attempts: 106

SettingsSettingsSettings
Syit Core Java 2019 - Quiz

.


Questions and Answers
  • 1. 

    JAVA was first called as?

    • A. 

      Banyan 

    • B. 

      Oak

    • C. 

      Mahagony

    • D. 

      Sal

    Correct Answer
    B. Oak
    Explanation
    JAVA was originally developed by James Gosling and his team at Sun Microsystems in the early 1990s. They initially named the language "Oak" after an oak tree that stood outside Gosling's office. However, due to trademark issues, they had to change the name to "JAVA" later on. Therefore, the correct answer is Oak.

    Rate this question:

  • 2. 

    Which component is responsible for converting bytecode into machine specific code?

    • A. 

      JVM

    • B. 

      JDK

    • C. 

      JIT

    • D. 

      JRE

    Correct Answer
    A. JVM
    Explanation
    JVM (Java Virtual Machine) is responsible for converting bytecode into machine specific code. It is an essential component of the Java platform that executes Java programs by interpreting the bytecode and translating it into machine code that can be understood by the underlying operating system. JVM acts as an intermediary between the Java program and the operating system, ensuring platform independence by providing a layer of abstraction. It also provides various services such as memory management, garbage collection, and exception handling.

    Rate this question:

  • 3. 

    Which statement is true about java?

    • A. 

      Platform independent programming language

    • B. 

      Platform dependent programming language

    • C. 

      Code dependent programming language

    • D. 

      Sequence dependent programming language

    Correct Answer
    A. Platform independent programming language
    Explanation
    Java is a platform-independent programming language because it can run on any operating system or platform that has a Java Virtual Machine (JVM) installed. This means that Java code written on one platform can be executed on any other platform without the need for any modifications. The JVM acts as an intermediary between the Java code and the underlying operating system, allowing Java programs to be executed on different platforms without any compatibility issues. This platform independence is one of the key features of Java, making it a popular choice for developing cross-platform applications.

    Rate this question:

  • 4. 

    Which of the below is invalid identifier with the main method?

    • A. 

      Public

    • B. 

      Static

    • C. 

      Private

    • D. 

      Final

    Correct Answer
    D. Final
    Explanation
    The keyword "final" is an invalid identifier with the main method because it is a reserved keyword in Java and cannot be used as an identifier. Reserved keywords have predefined meanings in the language and cannot be used for variable names, method names, or class names. The main method is a special method in Java that serves as the entry point for a program, and it requires a valid identifier as its name.

    Rate this question:

  • 5. 

    What is the extension of java code files?

    • A. 

      .class

    • B. 

      .java

    • C. 

       .txt

    • D. 

      .js

    Correct Answer
    B. .java
    Explanation
    The extension of java code files is .java. This is the standard file extension used for Java programming language source code files. It helps to identify and distinguish Java files from other types of files.

    Rate this question:

  • 6. 

    Java is Architecture Neutral.

    • A. 

      True

    • B. 

      False

    Correct Answer
    A. True
    Explanation
    Java is considered architecture neutral because it can run on any platform or operating system without needing to be recompiled. This is achieved through the use of the Java Virtual Machine (JVM), which interprets Java bytecode and translates it into machine code that is specific to the underlying hardware. This allows Java programs to be written once and run anywhere, making it a highly portable and versatile programming language.

    Rate this question:

  • 7. 

    Decrement operator, −−, decreases the value of variable by what number?  

    • A. 

      1

    • B. 

      2

    • C. 

      3

    • D. 

      4

    Correct Answer
    A. 1
    Explanation
    The decrement operator, --, decreases the value of a variable by 1.

    Rate this question:

  • 8. 

     Which of the following is not OOPS concept in Java?

    • A. 

      Inheritance

    • B. 

      Encapsulation

    • C. 

      Polymorphism

    • D. 

      Compilation

    Correct Answer
    D. Compilation
    Explanation
    Compilation is not an OOPS concept in Java because it is a process of translating high-level programming language code into machine-readable code. OOPS concepts in Java are Inheritance, Encapsulation, and Polymorphism, which are fundamental principles that allow for modular and reusable code. Compilation is a step that occurs during the execution of the OOPS concepts but is not a concept itself.

    Rate this question:

  • 9. 

    Which of the following is a method having same name as that of its class?

    • A. 

      Finalize

    • B. 

      Delete

    • C. 

      Class

    • D. 

      Constructor

    Correct Answer
    D. Constructor
    Explanation
    A constructor is a special method in a class that has the same name as the class itself. It is used to initialize the objects of that class and is automatically called when an object is created. Therefore, the correct answer is constructor.

    Rate this question:

  • 10. 

    What is the return type of Constructors?

    • A. 

      Int

    • B. 

      Float

    • C. 

      Void

    • D. 

      None of the mentioned

    Correct Answer
    D. None of the mentioned
    Explanation
    Constructors do not have a return type. They are special methods that are used to initialize objects of a class. Their purpose is to allocate memory for the object and initialize its member variables. Since constructors do not return any value, the return type is "void". Therefore, the correct answer is "none of the mentioned".

    Rate this question:

  • 11. 

    Which function is used to perform some action when the object is to be destroyed?

    • A. 

      Finalize()

    • B. 

      Delete()

    • C. 

      Main()

    • D. 

      None of the mentioned

    Correct Answer
    A. Finalize()
    Explanation
    The finalize() function is used to perform some action when an object is about to be destroyed. This function is called by the garbage collector before reclaiming the memory occupied by the object. It allows the programmer to clean up any resources or perform any necessary operations before the object is no longer accessible. The delete() function is used to deallocate memory for dynamically allocated objects, but it does not specifically handle the destruction of an object. The main() function is the entry point of a program and is not directly related to the destruction of objects. Therefore, the correct answer is finalize().

    Rate this question:

  • 12. 

    What is the output of this program?
    1. class box
    2. {
    3. int width;
    4. int height;
    5. int length;
    6. int volume;
    7. box()
    8. {
    9. width = 5;
    10. height = 5;
    11. length = 6;
    12. }
    13. void volume()
    14. {
    15. volume = width*height*length;
    16. }
    17. }
    18. class constructor_output
    19. {
    20. public static void main(String args[])
    21. {
    22. box obj = new box();
    23. obj.volume();
    24. System.out.println(obj.volume);
    25. }
    26. }

    • A. 

      200

    • B. 

      100

    • C. 

      150

    • D. 

      250

    Correct Answer
    C. 150
    Explanation
    The output of this program is 150. This is because the program defines a class called "box" with instance variables width, height, length, and volume. It also has a default constructor that initializes the width, height, and length variables to specific values. The class also has a method called "volume" which calculates the volume of the box by multiplying the width, height, and length. In the main method of the "constructor_output" class, an object of the "box" class is created and its volume is calculated using the volume method. Finally, the volume of the box is printed, which is 150 in this case.

    Rate this question:

  • 13. 

    Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?

    • A. 

      Delete

    • B. 

      Free

    • C. 

      New

    • D. 

      None of the mentioned

    Correct Answer
    D. None of the mentioned
    Explanation
    The correct answer is "none of the mentioned" because Java does not provide an explicit operator to free the memory of an object. Instead, Java relies on automatic garbage collection, where the Java runtime environment automatically identifies and frees the memory of objects that are no longer referenced by the program.

    Rate this question:

  • 14. 

    Which of these keywords is used to make a class?

    • A. 

      Class

    • B. 

      Struct

    • C. 

      Int

    • D. 

      None of the mentioned

    Correct Answer
    A. Class
    Explanation
    The keyword "class" is used to make a class in programming. A class is a blueprint for creating objects, and it defines the properties and behaviors that the objects will have. By using the "class" keyword, we can define a new class and then create instances of that class. The other keywords mentioned, "struct" and "int", are not used to make a class. "struct" is used to define a structure, which is similar to a class but with different default access modifiers. "int" is a data type used to represent integers. Therefore, the correct keyword to make a class is "class".

    Rate this question:

  • 15. 

    Which of these operators is used to allocate memory for an object?

    • A. 

      Malloc

    • B. 

      Alloc

    • C. 

      New

    • D. 

      Give

    Correct Answer
    C. New
    Explanation
    The "new" operator is used to allocate memory for an object. It is a keyword in C++ that dynamically allocates memory for a single object and returns a pointer to that object. This allows for dynamic memory allocation during runtime, which is useful when the size or number of objects needed is not known at compile time. The "malloc" and "alloc" options are not correct as they are not valid operators in C++ for memory allocation. The "give" option is not a valid operator at all.

    Rate this question:

  • 16. 

    What is the output of this program?
    1. class box
    2. {
    3. int width;
    4. int height;
    5. int length;
    6. }
    7. class mainclass
    8. {
    9. public static void main(String args[])
    10. {
    11. box obj = new box();
    12. obj.width = 10;
    13. obj.height = 2;
    14. obj.length = 10;
    15. int y = obj.width * obj.height * obj.length;
    16. System.out.print(y);
    17. }
    18. }

    • A. 

      12

    • B. 

      200

    • C. 

      300

    • D. 

      400

    Correct Answer
    B. 200
    Explanation
    The program defines a class called "box" with three integer variables: width, height, and length. It also defines another class called "mainclass" with a main method. Inside the main method, an object of the "box" class is created and assigned values to its width, height, and length variables. Then, the variables are multiplied together and stored in the variable "y". Finally, the value of "y" is printed. In this case, the width is 10, the height is 2, and the length is 10, so the output will be 10 * 2 * 10 = 200.

    Rate this question:

  • 17. 

    Which of these access specifiers must be used for main() method?

    • A. 

      Private

    • B. 

      Public

    • C. 

      Protected

    • D. 

      None of the mentioned

    Correct Answer
    B. Public
    Explanation
    The main() method in Java must be declared as public. This is because the main() method serves as the entry point for the Java program, and it needs to be accessible to the Java Virtual Machine (JVM) in order to execute the program. Declaring it as public allows other classes and packages to access and invoke the main() method.

    Rate this question:

  • 18. 

    Which of these access specifier must be used for class so that it can be inherited by another subclass?

    • A. 

      Public

    • B. 

      Private

    • C. 

      Protected

    • D. 

      None of the mentioned

    Correct Answer
    A. Public
    Explanation
    The access specifier "public" must be used for a class so that it can be inherited by another subclass. This means that the class can be accessed and inherited by any other class, regardless of its location or package. The "public" access specifier provides the highest level of accessibility for a class.

    Rate this question:

  • 19. 

    Which method can be defined only once in a program?

    • A. 

      Main method

    • B. 

      Finalize method

    • C. 

      Static method

    • D. 

      Private method

    Correct Answer
    A. Main method
    Explanation
    The main method can be defined only once in a program because it serves as the entry point for the program's execution. It is the method that is called first when the program is run, and it is responsible for starting the program's execution and invoking other methods as needed. Defining multiple main methods in a program would create ambiguity and confusion, as the program would not know which method to call first. Therefore, the main method is unique and can only be defined once in a program.

    Rate this question:

  • 20. 

    Using which of the following, multiple inheritance in Java can be implemented?

    • A. 

      Interfaces

    • B. 

      Multithreading

    • C. 

      Protected methods

    • D. 

      Private methods

    Correct Answer
    A. Interfaces
    Explanation
    Multiple inheritance in Java can be implemented using interfaces. In Java, a class can implement multiple interfaces, allowing it to inherit the methods and constants defined in those interfaces. This allows for the implementation of multiple inheritance-like behavior, where a class can inherit from multiple sources. Interfaces provide a way to achieve this without the complexities and ambiguity that can arise from traditional multiple inheritance. By implementing multiple interfaces, a class can inherit and utilize the functionality defined in each interface, providing a flexible and modular approach to inheritance in Java.

    Rate this question:

  • 21. 

    What is not type of inheritance?

    • A. 

      Single inheritance

    • B. 

      Double inheritance

    • C. 

      Hierarchical inheritanc

    • D. 

      Multiple inheritance

    Correct Answer
    B. Double inheritance
    Explanation
    Double inheritance is not a type of inheritance because it does not exist in object-oriented programming. Inheritance is a mechanism where a class inherits properties and behaviors from another class. Single inheritance allows a class to inherit from only one superclass, while multiple inheritance allows a class to inherit from multiple superclasses. Hierarchical inheritance is a type of inheritance where multiple classes inherit from a single superclass. However, double inheritance is not a recognized concept in inheritance.

    Rate this question:

  • 22. 

    Which of the following is used for implementing inheritance through an interface?

    • A. 

      Inherited

    • B. 

      Using

    • C. 

      Extends

    • D. 

      Implements

    Correct Answer
    D. Implements
    Explanation
    The correct answer is "implements". In Java, the "implements" keyword is used to implement inheritance through an interface. When a class implements an interface, it inherits all the methods declared in that interface and must provide implementations for those methods. This allows for code reusability and polymorphism, as multiple classes can implement the same interface and be treated interchangeably.

    Rate this question:

  • 23. 

    What would be the result if a class extends two interfaces and both have a method with same name and signature?

    • A. 

      Runtime error

    • B. 

      Compile time error

    • C. 

      Code runs successfully

    • D. 

      First called method is executed successfully

    Correct Answer
    B. Compile time error
    Explanation
    When a class extends two interfaces and both interfaces have a method with the same name and signature, it will result in a compile-time error. This is because the class is required to provide an implementation for all the methods defined in the interfaces it extends. Since both interfaces have a method with the same name and signature, it is ambiguous for the class to determine which method to implement. Therefore, the compiler will throw an error indicating that the class must resolve the ambiguity by providing its own implementation for the conflicting method.

    Rate this question:

  • 24. 

    Which of these keywords are used to define an abstract class?

    • A. 

      Abst

    • B. 

      Abstract

    • C. 

      Abstrat

    • D. 

      Static class

    Correct Answer
    C. Abstrat
    Explanation
    The correct answer is "abstract". In object-oriented programming, the "abstract" keyword is used to define an abstract class. An abstract class cannot be instantiated and is meant to be a blueprint for other classes to inherit from. It can contain both abstract and non-abstract methods, and any class that inherits from it must implement the abstract methods. The other options mentioned, "abst", "Abstrat", and "static class", are not valid keywords for defining an abstract class.

    Rate this question:

  • 25. 

    Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

    • A. 

      Do-while

    • B. 

      While

    • C. 

      For

    • D. 

      None of the mentioned

    Correct Answer
    A. Do-while
    Explanation
    The do-while loop will execute the body of the loop even when the condition controlling the loop is initially false. This is because the condition is checked at the end of the loop iteration, so the body of the loop will always execute at least once before the condition is evaluated.

    Rate this question:

  • 26. 

    What is true about a break?

    • A. 

      Break stops the execution of entire program

    • B. 

      Break halts the execution and forces the control out of the loop

    • C. 

      Break forces the control out of the loop and starts the execution of next iteration

    • D. 

       Break halts the execution of the loop for certain time frame

    Correct Answer
    B. Break halts the execution and forces the control out of the loop
    Explanation
    A break statement in programming is used to terminate the current loop and force the control to exit the loop. Once a break statement is encountered, the execution of the loop is immediately halted and the control is transferred to the next statement after the loop. This means that the remaining iterations of the loop are skipped, and the program continues executing from the point immediately after the loop. Therefore, the given answer "Break halts the execution and forces the control out of the loop" is true.

    Rate this question:

  • 27. 

    Which of the following is not a decision making statement?

    • A. 

      If

    • B. 

      If-else

    • C. 

      Switch

    • D. 

       do-while

    Correct Answer
    D.  do-while
    Explanation
    A do-while statement is not a decision-making statement because it is a looping statement. It executes a block of code repeatedly until a specified condition becomes false. In contrast, if, if-else, and switch statements are decision-making statements that allow the program to make decisions and choose different paths of execution based on certain conditions.

    Rate this question:

  • 28. 

    The while loop repeats a set of code while the condition is not met?

    • A. 

      True

    • B. 

      False

    Correct Answer
    B. False
    Explanation
    The while loop repeats a set of code while the condition is met, not while the condition is not met. Therefore, the correct answer is False.

    Rate this question:

  • 29. 

    What is the output of this program?
    1. class operators
    2. {
    3. public static void main(String args[])
    4. {
    5. int var1 = 5;
    6. int var2 = 6;
    7. int var3;
    8. var3 = ++ var2 * var1 / var2 + var2;
    9. System.out.print(var3);
    10. }
    11. }

    • A. 

      10

    • B. 

      11

    • C. 

      12

    • D. 

      56

    Correct Answer
    C. 12
    Explanation
    The program initializes three variables, var1 with a value of 5, var2 with a value of 6, and var3. The expression var3 = ++var2 * var1 / var2 + var2 is then evaluated.

    The prefix increment operator (++var2) increases the value of var2 by 1 before the multiplication operation. So, var2 becomes 7.

    Then, the multiplication operation is performed: 7 * 5 = 35.

    Next, the division operation is performed: 35 / 7 = 5.

    Finally, the addition operation is performed: 5 + 7 = 12.

    Therefore, the output of the program is 12.

    Rate this question:

  • 30. 

    Which of these keywords is used to define packages in Java?

    • A. 

      A) pkg

    • B. 

      B) Pkg

    • C. 

      C) package

    • D. 

      D) Package

    Correct Answer
    C. C) package
    Explanation
    The correct answer is "c) package". In Java, the keyword "package" is used to define packages. Packages are used to organize and group related classes and interfaces together. By using packages, it becomes easier to manage and maintain large-scale Java applications. The package keyword is always written in lowercase.

    Rate this question:

  • 31. 

    Which of these access specifiers can be used for a class so that its members can be accessed by a different class in the different package?

    • A. 

      A) Public

    • B. 

      B) Protected

    • C. 

      C) Private

    • D. 

      D) No Modifier

    Correct Answer
    A. A) Public
    Explanation
    The correct answer is "a) Public". The "public" access specifier allows the class members to be accessed by a different class in a different package. Public access specifier has the widest scope and allows unrestricted access to the class members from any other class in any package.

    Rate this question:

  • 32. 

    An exception is an event, which occurs during the execution of a program that disrupts the normal flow of the program's instructions.

    • A. 

      True

    • B. 

      False

    Correct Answer
    A. True
    Explanation
    This statement is true because an exception is indeed an event that can occur during the execution of a program, causing it to deviate from its normal flow. When an exception is encountered, the program's instructions are interrupted, and the control is transferred to a specific exception-handling routine. This allows the program to handle and recover from unexpected errors or exceptional conditions that may arise during its execution.

    Rate this question:

  • 33. 

    Java Virtual Machine is  independent

    • A. 

      True

    • B. 

      False

    Correct Answer
    B. False
    Explanation
    The statement "Java Virtual Machine is independent" is false. The Java Virtual Machine (JVM) is not independent as it is platform-dependent. JVM is designed to run Java bytecode, which is a platform-independent intermediate code. However, the JVM itself needs to be installed on the specific operating system in order to execute the bytecode. Therefore, the JVM is not independent and requires platform-specific implementations.

    Rate this question:

  • 34. 

    What is the return type of lambda expression?

    • A. 

      A) String

    • B. 

      B) Object

    • C. 

      C) void

    • D. 

      D) Function

    Correct Answer
    D. D) Function
    Explanation
    The return type of a lambda expression can be any valid data type, including primitive types, objects, or even void. In this case, the correct answer is d) Function, which represents a lambda expression that returns a value.

    Rate this question:

  • 35. 

    Lambda Expression are useful to write shorthand Code and hence saves the effort of writing lengthy Code.

    • A. 

      True

    • B. 

      False

    Correct Answer
    A. True
    Explanation
    Lambda expressions in programming languages like Java are indeed useful for writing shorthand code. They allow developers to write concise and compact code by eliminating the need for writing lengthy and repetitive code blocks. Lambda expressions are particularly handy when working with functional interfaces, allowing for more efficient and readable code. Therefore, the given answer, "True," is correct.

    Rate this question:

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.