0% found this document useful (0 votes)
13 views11 pages

JP Assignment 6

The document consists of a series of multiple-choice questions related to Java programming concepts, covering topics such as abstract classes, method overloading, boolean values, applet life cycles, and exception handling. It includes questions about Java syntax, data types, object-oriented programming principles, and various Java methods and keywords. The questions test knowledge on both basic and advanced features of Java, making it a comprehensive quiz for learners.
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)
13 views11 pages

JP Assignment 6

The document consists of a series of multiple-choice questions related to Java programming concepts, covering topics such as abstract classes, method overloading, boolean values, applet life cycles, and exception handling. It includes questions about Java syntax, data types, object-oriented programming principles, and various Java methods and keywords. The questions test knowledge on both basic and advanced features of Java, making it a comprehensive quiz for learners.
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
You are on page 1/ 11

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

(A) Abst
(B) Abstract
(C) Abstract class
(D) Virtual

2. Which of these can be overloaded?


(A) Methods
(B) Constructors
(C) All of the mentioned
(D) None of the mentioned

3. What is boolean in Java?


(A) A value consisting of only true and false value
(B) A value consisting of 8 values
(C) Only True value in Java
(D) All of these

4. Which of the following is a super class of every class in Java?


(A) ArrayList
(B) Abstract class
(C) Object class
(D) String

5. What is Truncation in Java?


(A) Floating-point value assigned to a floating type
(B) Floating-point value assigned to an integer type
(C) Integer value assigned to a floating type
(D) None of the above

6. Which of these methods can be used to output a string in an applet?


(A) Display
(B) Paint
(C) drawString
(D) Transient

7. Which state is not part of the life cycle of an applet?


(A) Start
(B) Destroy
(C) Display
(D) Stop
8. Which of the options leads to the portability & security of Java?
(A) Bytecode is executed by JVM
(B) The applet makes the Java code secure & portable
(C) Use of exception handling
(D) Dynamic binding between objects

9. Applet viewer runs the applet file in the form of:


(A) .doc file
(B) .html file
(C) .xml file
(D) .gif file

10. What is the default value of char in Java?


(A) 20'
(B) '\u0000'
(C) ₹140000
(D) None of the above

11. A variable’s _______ indicates where the variable can be used in an application
code.
(A) Scope
(B) Lifetime
(C) Place
(D) Position

12. Which is a valid variable name in Java?


(A) 5th team
(B) &5th team
(C) fifth_team
(D) None of the above

13. Which of the following is not a type of exception in Java?


(A) Checked exception
(B) Unchecked exception
(C) Error
(D) Warning

14. The command-line arguments are passed at:


(A) The time of executing a Java program
(B) The time of compiling a Java program
(C) Both (A) & (B)
(D) None of the above
15. What is a subclass in Java?
(A) A subclass is a class declared inside a class
(B) A subclass is a class that extends another class
(C) A subclass is a class outside the package
(D) None of the above

16. Which Java method is used to clear elements of an ArrayList?


(A) deleteAll()
(B) delete()
(C) clearAll()
(D) clear()

17. The trim() method in Java is used to:


(A) Remove the given character
(B) Remove the values after the given index
(C) Remove leading and trailing spaces
(D) None of these

18. What is the full form of AWT in Java?


(A) Absolute Window Toolkit
(B) Abstract Window Toolkit
(C) Absolute Wear Kit
(D) Abstract Window Tools

19. Which statement is correct for private members in Java?


(A) Access outside the class is allowed
(B) Any class can access it
(C) Declared using private keyword
(D) All of these

20. Which of the following is used to declare, construct, and initialize an array?
(A) int an[][] = { {1, 2, 3}, {1, 4} };
(B) int an[] = new int(5);
(C) int an() = new int[];
(D) array an = new array();

21. Encapsulation is:


(A) Wrapping up of data and related functions into a single entity
(B) Creating special methods
(C) Creating special data structure
(D) None of these

22. How many threads can be executed at a time?


(A) Only one thread
(B) Multiple threads
(C) Only main() thread
(D) Two threads

23. The correct syntax to import the math library in Java is:
(A) import java.lang.math;
(B) import math;
(C) import java.math.*;
(D) All of these

24. Which keyword is used for accessing the features of a package?


(A) package
(B) import
(C) extends
(D) export

25. Which of these cannot be used as a variable name in Java?


(A) Identifier and keyword
(B) Identifier
(C) Keyword
(D) None

26. What makes Java platform independent?


(A) Advanced programming language
(B) It uses bytecode for execution
(C) Class compilation
(D) All of the above

27. What is file handling in Java?


(A) It is used for creating, deleting, and modifying files using a Java program
(B) Creating a new method
(C) Filing method to different file to extract them better
(D) All of these

28. Runnable is a:
(A) Class
(B) Method
(C) Variable
(D) Interface

29. Wrapper class in Java is:


(A) Used to encapsulate primitive data types
(B) Used to declare new classes called wrapper
(C) Used to create a new instance of the class
(D) None of these

30. Who invented Java programming?


(A) Guido van Rossum
(B) James Gosling
(C) Dennis Ritchie
(D) Bjarne Stroustrup

31. Which of the following array declarations is correct in Java?


(A) int[] an = {1, 2, 3};
(B) int[] an = (1,2,3);
(C) int[] an = 0;
(D) int an[] (1,2,3);

32. The super keyword is used to:


(A) Access instance of the parent class
(B) Access instance of the same class
(C) Access instance of child class
(D) Access instance of friend class

33. Which one of the following is not a Java feature?


(A) Object-oriented
(B) Use of pointers
(C) Portable
(D) Dynamic and extensible

34. What is the extension of Java code files?


(A) .js
(B) .txt
(C) .class
(D) .java

35. The break statement in Java is used to:


(A) Terminate from the loop immediately
(B) Terminate from the program immediately
(C) Skip the current iteration
(D) All of these

36. Which of the following is not an OOPS concept in Java?


(A) Polymorphism
(B) Inheritance
(C) Compilation
(D) Encapsulation
37. What is not the use of the this keyword in Java?
(A) Referring to the instance variable when a local variable has the same name
(B) Passing itself to the method of the same class
(C) Passing itself to another method
(D) Calling another constructor in constructor chaining

38. Which class in Java is used to take input from the user?
(A) Scanner
(B) Input
(C) Applier
(D) None

39. Which of the following is a type of polymorphism in Java programming?


(A) Multiple polymorphism
(B) Compile-time polymorphism
(C) Multilevel polymorphism
(D) Execution-time polymorphism

40. What will be the output of the following Java program?


(D) 640

41. What will be the output of the following Java program?


(D) 640

42. What will be the output of the following Java program?


(A) 12345

43. What is the extension of compiled Java classes?


(A) .txt
(B) .js
(C) .class
(D) .java

44. Which exception is thrown when Java is out of memory?


(A) Memory Error
(B) Out of Memory Error
(C) Memory Out of Bounds Exception
(D) Memory Full Exception

45. What is the numerical range of a char data type in Java?


(A) 0 to 256
(B) -128 to 127
(C) 0 to 65535
(D) 0 to 32767
46. Which keyword is used by the method to refer to the object that invoked it?
(A) Import
(B) Catch
(C) Abstract
(D) This

47. Which of these statements is incorrect about threads?


(A) start() method is used to begin execution of the thread
(B) run() method is used to begin execution of a thread before start() method in special
cases
(C) A thread can be formed by implementing the Runnable interface only
(D) None of the above

48. Which of these keywords must be used to inherit a class?


(A) Super
(B) This
(C) Extent
(D) Extends

49. What is the process of defining two or more methods with the same name but
different parameters in the same class?
(A) Method overloading
(B) Method overriding
(C) Method hiding
(D) None of the mentioned

50. Which of these is the correct way of inheriting class A by class B?


(A) Class B + Class A
(B) Method overriding
(C) Class B inherits class A {}
(D) Class B extends A

51. Which one of the following is not an access modifier?


(A) Protected
(B) Void
(C) Public
(D) Private

52. String in Java is a?


(A) Class
(B) Object
(C) Variable
(D) Character array
53. Which of these keywords is used to refer to a member of the base class from a
subclass?
(A) Upper
(B) Supper
(C) This
(D) None of the mentioned

54. Which of these methods of the String class can be used to test two strings for
equality?
(A) isequal()
(B) isequals()
(C) equal()
(D) equals()

55. Output of System.out.println(obj.charAt(3)); when obj = "I LIKE JAVA"


(A) I
(B) L
(C) K
(D) J

56. Can command line arguments be converted into int automatically if required?
(A) Yes
(B) No
(C) Compiler Dependent
(D) Only ASCII characters can be converted

57. Which of these methods are given parameters via command arguments?
(A) main()
(B) recursive() method
(C) Any method
(D) System defined methods

58. Which of these keywords can be used to prevent method overriding?


(A) Static
(B) Constant
(C) Protected
(D) Final

59. What is the default relationship between thread and runnable?


(A) Thread extends runnable
(B) Thread implements runnable
(C) They are not related
(D) None of these
60. Which is the superclass of all exception classes?
(A) Exception
(B) Object
(C) Error
(D) Throwable

61. Which keyword is used to prevent the content of a variable from being
modified?
(A) Final
(B) Constant
(C) Static
(D) None of the above

62. What was Java called before?


(A) Java
(B) Java x
(C) Classes & Java
(D) Oak

63. Which of these is supported by method overriding in Java?


(A) Encapsulation
(B) Abstraction
(C) Polymorphism
(D) None of the above

64. When a local variable has same name as instance variable, it's called:
(A) Serialization
(B) Variable shadowing
(C) Polymorphism
(D) Multi-threading

65. Which is used to print your name in an applet?


(A) drawText("my Name")
(B) drawLine("my Name", 10, 10)
(C) drawLetters(10, 10, "my Name")
(D) drawString("my Name", 10, 10)

66. Java array is a collection of:


(A) Similar type of elements
(B) Different type of elements
(C) Heterogeneous data
(D) Both (A) and (C)
67. Which class objects form a dynamic array?
(A) Array list
(B) Vector
(C) Map
(D) Array list & Vector

68. Automatic type conversion is possible from:


(A) Int to long
(B) Long to int
(C) Both Above
(D) None Above

69. Which of these is a non-access modifier?


(A) Public
(B) Private
(C) Native
(D) All of these

70. Jar in Java stands for:


(A) Java archive
(B) Java application runtime
(C) Java application runner
(D) None of these

71. In Java, recursion is:


(A) Method
(B) A process allowing methods to call itself
(C) The process to call methods
(D) None

72. Method to generate random numbers in Java:


(A) random.nextInt()
(B) random()
(C) rand()
(D) All of these

73. Which keyword is used for exception handling?


(A) Exep
(B) Excep Hand
(C) Throw
(D) All of the above

74. Method that deletes a file in Java:


(A) file.delete()
(B) file.remove()
(C) file.garbage()
(D) file.dump()

75. Class used to write bytes to a file:


(A) File Input Stream
(B) File Output Stream
(C) File Buffer Stream
(D) File String Stream

76. Method to extract the length of a string in Java:


(A) length()
(B) len()
(C) size of()
(D) size()

You might also like