Core Java Multiple Choice Questions With Answers 2018

Interview Questions

Core Java Multiple Choice Questions With Answers 2018. Here Coding compiler sharing a list of 40 Java Objective Questions and Answers for freshers and experienced Java developers. We hope that these Java MCQ Questions will help you to crack your next Java interview. All the best for your future and happy Java learning.

Core Java Multiple Choice Questions

1) A process that involves recognizing and focusing on the important characteristics of a situation or object is known as:

(a) Encapsulation (b) Polymorphism
(c) Abstraction (d) Inheritance
(e) Object persistence.

A) c

2) Which statement is true regarding an object?

(a) An object is what classes instantiated are from
(b) An object is an instance of a class
(c) An object is a variable
(d) An object is a reference to an attribute
(e) An object is not an instance of a class.

A) b

3) In object-oriented programming, composition relates to

(a) The use of consistent coding conventions
(b) The organization of components interacting to achieve a coherent, common behavior
(c) The use of inheritance to achieve polymorphic behavior
(d) The organization of components interacting not to achieve a coherent common behavior
(e) The use of data hiding to achieve polymorphic behavior.

A) b

4) In object-oriented programming, new classes can be defined by extending existing classes. This is an example of:

(a) Encapsulation (b) Interface
(c) Composition (d) Inheritance (e) Aggregation.

A) d

5) Which of the following does not belong: If a class inherits from some other class, it should

(a) Make use of the parent class’s capabilities
(b) Over-ride or add the minimum to accomplish the derived class’ purpose
(c) Over-ride all the methods of its parent class
(d) Make sure the result “IS-A-KIND-OF” its base class
(e) Make sure the result “contains” its base class.

A) c

6) Object-oriented inheritance models the

(a) “is a kind of” relationship
(b) “has a” relationship
(c) “want to be” relationship
(d) inheritance does not describe any kind of relationship between classes
(e) “contains” of relationship.

A) a

7) The wrapping up of data and functions into a single unit is called

(a) Encapsulation (b) Abstraction
(c) Data Hiding (d) Polymorphism (e) Message passing.

A) a

8) Polymorphism

(a) Is not supported by Java
(b) Refers to the ability of two or more objects belonging to different classes to respond to exactly the same message in different class-specific ways
(c) Simplifies code maintenance
(d) Not simplifies code maintenance
(e) Refers to the ability of two or more objects belonging to different classes to respond to exactly the same message in different class-specific ways and simplifies code maintenance.

A) e

9) In object-oriented programming, new classes can be defined by extending existing classes. This is an example of:

(a) Encapsulation (b) Interface (c) Composition
(d) Inheritance (e) Aggregation.

A) d

10) Given a class named student, which of the following is a valid constructor declaration for the class?

(a) Student (student s) { } (b) Student student ( ) { }
(c) Private final student ( ) { } (d) Void student ( ) { }
(e) Static void student(){ }.

A) a

Core Java Multiple Choice Questions With Answers

11) What is garbage collection in the context of Java?

(a) The operating system periodically deletes all of the java files available on the system.
(b) Any package imported in a program and not used is automatically deleted.
(c) When all references to an object are gone, the memory used by the object is automatically reclaimed.
(d) The JVM checks the output of any Java program and deletes anything that doesn’t make sense.
(e) When all references to an object are gone the memory used by the object is not reclaimed.

A) c

12) The concept of multiple inheritances is implemented in Java by

I. Extending two or more classes.
II. Extending one class and implementing one or more interfaces.
III. Implementing two or more interfaces.

(a) Only (II) (b) (I) and (II) (c) (II) and (III)
(d) Only (I) (e) Only (III).

A) c

13) In Java, declaring a class abstract is useful

(a) To prevent developers from further extending the class
(b) When it doesn’t make sense to have objects of that class
(c) When default implementations of some methods are not desirable
(d) To force developers to extend the class not to use its capabilities
(e) When it makes sense to have objects of that class.

A) b

14) What is the error in the following class definitions?

Abstract class xy
{
abstract sum (int x, int y) { }
}

(a) Class header is not defined properly.
(b) Constructor is not defined.
(c) Method is not defined properly
(d) Method is defined properly
(e) No error.

A) c

15) Which of these field declarations are legal within the body of an interface?

(a) Private final static int answer = 42 (b) public static int answer=42
(c) final static answer =42 (d) int answer
(e) No error.

A) b

16) A package is a collection of

(a) Classes (b) Interfaces (c) Editing tools
(d) Classes and interfaces (e) Editing tools and interfaces.

A) d

17) A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction?

(a) Declare the method with the keyword public
(b) Declare the method with the keyword private
(c) Declare the method with the keyword protected
(d) Do not declare the method with any accessibility modifiers
(e) Declare the method with the keyword public and private.

A) d

18) Basic Java language functions are stored in which of the following java package?

(a) java.lang (b) java.io (c) java.net (d) java.util (e) java.awt

A) a

19) Which of the following is a member of the java.lang package?

(a) List (b) Queue (c) Math (d) Stack (e) Process.

A) b

20) Which of the following has a method names flush( )?

(a) Input stream (b) Output Stream
(c) Reader stream (d) Input reader stream
(e) Input output stream.

A) b

Core Java Multiple Choice Questions And Answers

Core Java Multiple Choice Questions # 21) What is the fundamental unit of information of writer streams?

(a) Characters (b) Bytes
(c) Files (d) Records (e) Information.

A) a

Core Java Multiple Choice Questions # 22) File class is included in which package?

(a) java.io package (b) java.lang package
(c) java.awt package (d) java.net.package
(e) java.util.package.

A) a

Core Java Multiple Choice Questions # 23) Given the code

String s1 = ” yes” ;
String s2 = ” yes ” ;
String s3 = new String ( s1);

Which of the following would equate to true?

(a) s1 == s2 (b) s1 = s2 (c) s3 == s1 (d) s3=s1 (e) s1!=s2.

A) a

Core Java Multiple Choice Questions # 24) URL stands for

(a) Universal reader locator (b) Universal reform loader
(c) Uniform resource loader (d) Uniform resource locator
(e) Uniform reader locator.

A) d

Core Java Multiple Choice Questions # 25) What is the sequence of major events in the life of an applet?

(a) init, start, stop, destroy (b) start, init , stop , destroy
(c) init, start , destroy, stop (d) init, start, destroy
(e) destroy, start, init, stop.

A) a

Core Java Multiple Choice Questions # 26) Which of the following is true in regard to applet execution?

(a) Applets loaded from the same computer where they are executing have the same restrictions as applets loaded from the network.
(b) Applets loaded and executing locally have none of the restrictions faced by applets that get loaded from the network.
(c) Applets loaded and executing locally have some restrictions faced by applets that get loaded from the network.
(d) Applets cant react to user input and change dynamically
(e) Applets can be run independently.

A) b

Core Java Multiple Choice Questions # 27) What is the return type of the method getID() defined in AWTEvent class

(a) Int (b) long (c) Object (d) Component (e) float.

A) a

Core Java Multiple Choice Questions # 28) Which of the following events will cause a thread to die?

(a) The method sleep( ) is called
(b) The method wait( ) is called
(c) Execution of the start( ) method ends
(d) Execution of the run( ) method ends
(e) Execution of the run() method is called.

A) d

Core Java Multiple Choice Questions # 29) What will be the result of the expression 13 & 25?

(a) 38 (b) 25 (c) 9 (d) 12 (e) 21.

A) c

Core Java Multiple Choice Questions # 30) Which of the following statements are true regarding the finalize( ) method?

(a) The finalize ( ) method must be declared with protected accessibility
(b) The compiler will fail to compile the code that explicitly tries to call the finalize( ) method
(c) The body of the finalize ( ) method can only access other objects that are eligible for garbage collection
(d) The finalize ( ) method can be overloaded
(e) The finalize() method cant be overloaded.

A) d

Core Java Objective Questions And Answers

Core Java Multiple Choice Questions # 31) Which one of these is a valid method declaration?

(a)
void method1
(b)
void method2()
(c)
void method3(void)
(d)
method4()
(e)
methods(void).

A) b

Core Java Multiple Choice Questions # 32) Given a class named Book, which one of these is a valid constructor declaration for the class?

(a)
Book(Book b) { }
(b)
Book Book() { }
(c)
private final Book() { }
(d)
void Book() { }
(e)
abstract Book() { }.

A) a

Core Java Multiple Choice Questions # 33) What will be the result of attempting to compile the following program?

public class MyClass {
long var;
public void MyClass(long param) { var = param; } //(1)
public static void main(String[] args) {
MyClass a,b;
a = new MyClass(); //(2)
b = new MyClass(5); //(3)
}
}

(a)
A compilation ERROR will occur at (1), since constructors cannot specify a return value
(b)
A compilation error will occur at (2), since the class does not have a default constructor
(c)
A compilation error will occur at (3), since the class does not have a constructor which takes one argument of type int
(d)
The program will compile correctly
(e)
The program will compile and execute correctly.

A) c

Core Java Multiple Choice Questions # 34) Given the following class, which of these is valid way of referring to the class from outside of the package net.basemaster?

package net.basemaster;
public class Base {
// . . .
}
Select the correct answer.

(a)
By simply referring to the class as Base
(b)
By simply referring to the class as basemaster.Base
(c)
By simply referring to the class as net.basemaster.Base
(d)
By simply referring to the class as net.Base
(e)
By importing with net.* and referring to the class as basemaster.Base.

A) c

Core Java Multiple Choice Questions # 35) Which one of the following class definitions is a valid definition of a class that cannot be instantiated?

(a)
class Ghost
{
abstract void haunt();
}

(b)
abstract class Ghost
{
void haunt();
}

(c)
abstract class Ghost
{
void haunt() { };
}

(d)
abstract Ghost
{
abstract void haunt();
}

(e)
static class Ghost
{
abstract haunt();
}

A) c

Core Java MCQ Questions With Answers

36) Which one of the following class definitions is a valid definition of a class that cannot be extended?

(a)
class Link { }
(b)
abstract class Link { }
(c)
native class Link { }
(d)
static class Link { }
(e)
final class Link { }.

A) e

37) Given the following definition of a class, which fields are accessible from outside the package com.corporation.project?

package com.corporation.project;
public class MyClass
{
int i;
public int j;
protected int k;
private int l;
}
Select the correct answer.

(a)
Field i is accessible in all classes in other packages
(b)
Field j is accessible in all classes in other packages
(c)
Field k is accessible in all classes in other packages
(d)
Field l is accessible in all classes in other packages
(e)
Field l is accessible in subclasses only in other packages.

A) b

38) How restrictive is the default accessibility compared to public, protected, and private accessibility?

(a)
Less restrictive than public
(b)
More restrictive than public, but less restrictive than protected
(c)
More restrictive than protected, but less restrictive than private
(d)
More restrictive than private
(e)
Less restrictive than protected from within a package, and more restrictive than protected from outside a package.

A) c

39) Which statement is true about accessibility of members?

(a)
Private members are always accessible from within the same package
(b)
Private members can only be accessed by code from within the class of the member
(c)
A member with default accessibility can be accessed by any subclass of the class in which it is defined
(d)
Private members cannot be accessed at all
(e)
Package/default accessibility for a member can be declared using the keyword default.

A) b

40) Which of the following is true about the use of modifiers?

(a)
If no accessibility modifier (public, protected, and private) is specified for a member declaration, the member is only accessible for classes in the package of its class and subclasses of its class anywhere
(b)
You cannot specify accessibility of local variables. They are only accessible within the block in which they are declared
(c)
Subclasses of a class must reside in the same package as the class they extend
(d)
Local variables can be declared static
(e)
None of the above.

A) b

Related Java Interview Questions

  1. 60 Java Multiple Choice Questions
  2. Aricent Java Interview Questions
  3. Accenture Java Interview Questions
  4. Advanced Java Interview Questions For 5 8 10 Years Experienced
  5. Core Java Interview Questions For Experienced

OTHER INTERVIEW QUESTIONS

  1. Anaplan Interview Questions And Answers
  2. Tableau Multiple Choice Questions
  3. Python Coding Interview Questions
  4. CSS3 Interview Questions
  5. Linux Administrator Interview Questions
  6. SQL Interview Questions
  7. Hibernate Interview Questions
  8. Kubernetes Interview Questions
  9. Kibana Interview Questions
  10. Nagios Interview Questions
  11. Jenkins Interview Questions
  12. Chef Interview Questions
  13. Puppet Interview Questions
  14. RPA Interview Questions And Answers
  15. Android Interview Questions
  16. Mulesoft Interview Questions
  17. JSON Interview Questions
  18. PeopleSoft HRMS Interview Questions
  19. PeopleSoft Functional Interview Questions
  20. PeopleTools Interview Questions
  21. Peoplesoft Technical Interview Questions
  22. 199 Peoplesoft Interview Questions
  23. 200 Blue Prism Interview Questions
  24. Visualforce Interview Questions
  25. Salesforce Interview Questions
  26. 300 SSIS Interview Questions
  27. PHP Interview Questions And Answers
  28. Alteryx Interview Questions
  29. AWS Cloud Support Interview Questions
  30. Google Kubernetes Engine Interview Questions
  31. AWS Devops Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *