0% found this document useful (0 votes)
4 views6 pages

Java Ass-2

The document consists of a series of multiple-choice questions related to Java programming concepts, including features of Java, environment variables, data types, keywords, and method behaviors. It covers topics such as object-oriented principles, variable types, and control structures. The questions are designed to test knowledge on Java syntax, functionality, and best practices.

Uploaded by

vave30261876
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Java Ass-2

The document consists of a series of multiple-choice questions related to Java programming concepts, including features of Java, environment variables, data types, keywords, and method behaviors. It covers topics such as object-oriented principles, variable types, and control structures. The questions are designed to test knowledge on Java syntax, functionality, and best practices.

Uploaded by

vave30261876
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. Which of these is NOT a feature of Java?

A) Object-Oriented

B) Use of pointers

C) Platform independent

D) Robust

2. Which environment variable is used to set the path for Java binaries?

A) CLASSPATH

B) JAVA_HOME

C) PATH

D) JRE_PATH

3. What is the extension of a compiled Java class file?

A) .java

B) .txt

C) .class

D) .exe

4. Which of the following is a reserved keyword in Java?

A) object

B) strictfp

C) main

D) system

5. What is the default value of a boolean instance variable?

A) true

B) false

C) null

D) 0

6. Which data type is used to create a variable that should store text?

A) String

B) myString
C) txt

D) Char

7. How do you insert a single-line comment in Java code?

A) #

B) /*

C) //

D) --

8. What is the result of [Link](5 + 5 + "5");?

A) 555

B) 105

C) 510

D) 15

9. In a switch statement, which case is executed if no match is found?

A) break

B) else

C) default

D) final

10. What is the output of the expression 3 + 4 * 2?

A) 14

B) 11

C) 10

D) 24

11. Which process involves wrapping data and methods into a single unit?

A) Inheritance

B) Polymorphism

C) Encapsulation

D) Abstraction

12. What is the return type of a method that does not return any value?
A) int

B) null

C) void

D) empty

13. Which keyword is used to create an object in Java?

A) create

B) alloc

C) new

D) make

14. How many times can a constructor be called for a single object?

A) Only once

B) As many times as needed

C) Twice

D) Zero

15. Which keyword refers to the direct parent class of the current object?

A) this

B) super

C) parent

D) base

16. Static variables are stored in which part of memory?

A) Stack

B) Heap

C) Method Area

D) PC Register

17. Which of these cannot be used for a variable name?

A) identifier

B) keyword

C) instanceof
D) variable1

18. Can a constructor be overloaded in Java?

A) Yes

B) No

19. What is "Narrowing Casting"?

A) Converting a large type to a smaller type

B) Converting a small type to a larger type

C) Converting a String to a double

D) Converting an Object to a Class

20. Which modifier makes a member accessible only within its own class?

A) public

B) protected

C) private

D) default

21. Inheritance represents which type of relationship?

A) HAS-A

B) IS-A

C) USES-A

D) PART-OF

22. Which method structure is required to override a method in a subclass?

A) Same name, different parameters

B) Different name, same parameters

C) Same name, same parameters

D) Different name, different parameters

23. An abstract class can have:

A) Only abstract methods

B) Only concrete methods

C) Both abstract and concrete methods


D) Neither

24. Which keyword is used by a class to use an interface?

A) extends

B) inherits

C) implements

D) includes

25. Can we create an object (instantiate) of an Interface?

A) Yes

B) No

26. Which keyword is used to prevent method overriding?

A) static

B) final

C) abstract

D) private

27. What is the primary use of the continue statement?

A) To stop the whole loop

B) To skip the current iteration and move to the next one

C) To exit the method

D) To skip the whole program

28. Which of these is a mechanism for naming and visibility control of classes?

A) Interfaces

B) Packages

C) Inheritance

D) Polymorphism

29. Which of the following is true about this()?

A) It must be the first statement in a constructor.

B) It can be used anywhere in a method.

C) It refers to the parent constructor.


D) It is used to create a new object.

30. If a method is declared final, it means:

A) It cannot be overloaded.

B) It cannot be overridden.

C) It must be overridden.

D) It cannot be called.

You might also like