Blog about Programming Languages & Coding

Blog about Programming Languages & Coding
Contents for Computer Science, IT, B.Sc. CS & IT, M.Sc. CS & IT, MCA, BE CS & IT, ME CS & IT , Interview Questions, Books and Online Course Recommendations from Udemy, Coursera, etc

CORE JAVA MCQs with Answer

 

CORE JAVA MCQs with Answer


1. What is the range of short data type in Java? 

a) -128 to 127    

b) -32768 to 32767          

c) -2147483648 to 2147483647    

d) -5000 TO 5000

 

2. What is the range of byte data type in Java?  

a) -128 to 127    

b) -32768 to 32767          

c) -2147483648 to 2147483647    

d) -5000 TO 5000

               

3. An expression involving byte, int, and literal numbers is promoted to which of these?              

a) int    

b) long 

c) byte 

d) float

 

4. Which of these literals can be contained in float data type variable?   

a) -1.7e+308      

b) -3.4e+038      

c) +1.7e+308     

d) -3.4e+050

 

5. Which data type value is returned by all transcendental math functions?         

a) int     

b) float

c) double            

d)long

 

6. What will be the output of the following Java code?  

    class increment {                                                         

      public static void main(String args[])                                                 

         {                                                                    

             int g = 3;                                                 

              System.out.print(++g * 8);                                                           

         }                                                    

       }      

a) 25     

b) 24     

c) 32      

d) 33     

 

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

a) -128 to 127    

b) 0 to 256          

c) 0 to 32767      

d) 0 to 65535

 

8. Which of these coding types is used for data type characters in Java?

a) ASCII

b) ISO-LATIN-1 

c) UNICODE       

d) CODE

 

9. Which of these values can a boolean variable contain?             

a) True & False

b) 0 & 1                

c) Any integer value       

d) true

 

10. Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?      

a) ASCII               

b) ISO-LATIN-1 

c) LATIN1            

d) ASCII and ISO-LATIN1

 

11. Which one is a valid declaration of a boolean?            

a) boolean b1 = 1;           

b) boolean b2 = ‘false’; 

c) boolean b3 = false;   

d) boolean b4 = ‘true’

 

12. What will be the output of the following Java code?                                                                                

     class booloperators {                                                                

        public static void main(String args[])                                                                               

         {                                                                    

             boolean var1 = true;                                                                         

          boolean var2 = false;                                                                           

          System.out.println((var1 & var2));                                                                

         }                                                                    

    }

a) 0        

b) 1       

c) true  

d) false

 

13. Which of these is long data type literal?         

a) 0x99fffL          

b) ABCDEFG      

c) 0x99fffa          

d) 99671246

 

14. Which of these can be returned by the operator &?

a) Integer           

b) Boolean         

c) Character       

d) Integer or Boolean

 

15. Literals in java must be appended by which of these?             

a) L        

b) l         

c) D       

d) L and I

 

16. Which of these can not be used for a variable name in Java?

a) identifier       

b) keyword        

c) identifier & keyword

d) constant

 

17. How is Date stored in database?       

a) java.sql.Date

b) java.util.Date               

c) java.sql.DateTime      

d) java.util.DateTime

 

18. What does LocalTime represent?     

a) Date without time     

b) Time without Date   

c) Date and Time             

d) Date and Time with timezone

 

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

     class c                                                              

     {                                                        

         public void main( String[] args )                                                        

         {                                                    

             System.out.println( "Hello" + args[0] );                                                    

         }                                                    

     }        

a) Hello c             

b) Hello

c) Hello world   

d) Runtime Error

                                               

 20.Which of these operators is used to allocate memory to array variable in Java?           

a) malloc             

b) alloc 

c) new 

d) new malloc

 

21. Which of these is an incorrect array declaration?       

a) int arr[] = new int[5] 

b) int [] arr = new int[5]

c) int arr[] = new int[5] 

d) int arr[] = int [5] new

 

22. What will be the output of the following Java code?

    int arr[] = new int [5];                                                

    System.out.print(arr);                              

a) 0        

b) value stored in arr[0]

c) 00000               

d) Class name@ hashcode in hexadecimal form

                               

23. Which of these is an incorrect Statement?   

a) It is necessary to use new operator to initialize an array         

b) Array can be initialized using comma separated expressions surrounded by curly braces          

c) Array can be initialized when they are declared            

d) Array used curly braces

 

24. Which of these is necessary to specify at time of array initialization?

a) Row 

b) Column          

c) Both Row and Column             

d) Table

 

25. What will be the output of the following Java code?

     class evaluate                                                              

     {                                                        

         public static void main(String args[])                                                              

             {                                                

              int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};                                                       

              int n = 6;                                                

                 n = arr[arr[n] / 2];                                                          

              System.out.println(arr[n] / 2);                                                    

             }                                                

     }        

a) 3        

b) 0       

c) 6        

d) 1

                                               

26. Which of the following can be operands of arithmetic operators?     

a) Numeric         

b) Boolean         

c) Characters     

d) Numeric & Characters

 

27. Modulus operator, %, can be applied to which of these?       

a) Integers         

b) Floating – point numbers       

c)  Integers and floating – point numbers            

d) point numbers

 

28.With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?              

   1. x++;                                                              

   2. x = x + 1;                                                      

   3. x += 1;                                                          

   4. x =+ 1;          

a) 1, 2 & 3           

b) 1 & 4

c) 1, 2, 3 & 4       

d) 3 & 2

                                               

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

a) 1        

b) 2       

c) 3        

d) 4

 

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

     class increment                                                           

     {                                                        

         public static void main(String args[])                                                              

         {                                                                    

              int g = 3;                                                

              System.out.print(++g * 8);                                                           

         }                                                    

     }        

a) 25     

b) 24     

c) 32      

d) 33

                                               

31. Which of these is not a bitwise operator?     

a) &       

b) &=    

c) |=     

d) <=

 

32. Which operator is used to invert all the digits in a binary representation of a number?            

a) ~       

b) <<<  

c) >>>  

d) ^

 

33. On applying Left shift operator, <<, on integer bits are lost one they are shifted past which position bit?        

a) 1        

b) 32     

c) 33      

d) 31

 

34. Which right shift operator preserves the sign of the value?  

a) <<     

b) >>    

c) <<=  

d) >>=

 

35.What is the output of relational operators?  

a) Integer           

b) Boolean         

c) Characters     

d) Double

 

36. Which of these is returned by “greater than”, “less than” and “equal to” operators?

a) Integers         

b) Floating – point numbers       

c) Boolean         

d) Character

 

                                               

37. Which of these operators can skip evaluating right hand operand?   

a) !        

b) |       

c) &       

d) &&

 

38. Which of these statements is correct?           

a) true and false are numeric values 1 and 0       

b) true and false are numeric values 0 and 1       

c) true is any non zero value and false is 0            

d) true and false are non numeric values

 

39.Which of these have highest precedence?    

a) ()       

b) ++    

c) *        

d) >>

 

40. What is the value stored in x in the following lines of Java code?        

   int x, y, z;                                                         

    x = 0;                                                

    y = 1;                                                

    x = y = z = 8;                   

a) 0        

b) 1       

c) 9        

d) 8

                                                                                               

41. What is the value stored in x in the following lines of Java code?          

 int x, y, z;                                                           

    x = 0;                                                

    y = 1;                                                

    x = y = z = 8;                   

a) 0        

b) 1       

c) 9        

d) 8

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

a) pkg

b) Pkg

c) package

d) Package

 

43. Which of these is a mechanism for naming and visibility control of a class and its content?

a) Object

b) Packages

c) Interfaces

d) None of the Mentioned.

 

44. 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) Public

b) Protected

c) Private

d) Friendly

 

45. Which of the following is the correct way of importing an entire package ‘pkg’?

a) import pkg.

b) Import pkg.

c) import pkg.*

d) Import pkg.*

 

46. Which of the following is an incorrect statement about packages?

a) Package defines a namespace in which classes are stored

b) A package can contain other package within it

c) Java uses file system directories to store packages

d) A package can be renamed without renaming the directory in which the classes are stored

 

 

47. Which of these selection statements test only for equality?

a) if       

b) switch            

c) if & switch     

d) if-else

48. Which of these are selection statements in Java?     

a) if()    

b) for()

c) continue        

d) break

 

49. 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) for-each

 

50. Which of these jump statements can skip processing the remainder of the code in its body for a particular iteration?

a) break

b) return

c) exit

d) continue

 

51. Which of this statement is incorrect?

a) switch statement is more efficient than a set of nested ifs

b) two case constants in the same switch can have identical values

c) switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression

d) it is possible to create a nested switch statements

 

52. What is the output of Java program with IF statement?

if(1)

{

  System.out.println("OK");

}

A) OK

B) No output

C) Compiler error

D) Runtime error

 

 

 

53. If the condition of an IF-statement is false, which is true below.

 

A) IF block is executed.

B) ELSE block is executed.

C) Both IF and ELSE blocks are skipped.

D) Both IF and ELSE blocks are executed.

 

 

54. An ELSE statement must be preceded by ___ statement in Java.

A) IF

B) ELSE IF

C) IF or ELSE IF

D) IF ELSE

 

55. An IF statement in Java is also a ___ statement.

A) boolean

B) conditional

C) iterative

D) optional

 

56. An IF or ELSE IF statement accepts ___ as input before branching.

A) boolean

B) int

C) float

D) char

 

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

a) Inheritance

b) Encapsulation

c) Polymorphism

d) Compilation

 

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

a) Compile time polymorphism

b) Execution time polymorphism

c) Multiple polymorphism

d) Multilevel polymorphism

 

59. When does method overloading is determined?

a) At run time

b) At compile time

c) At coding time

d) At execution time

 

60. Which of these keywords is used to make a class?

a) class

b) struct

c) int

d) none of the mentioned

 

61. Which of the following is a valid declaration of an object of class Box?

a) Box obj = new Box();

b) Box obj = new Box;

c) obj = new Box();

d) new Box obj;

 

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

a) malloc

b) alloc

c) new

d) give

 

63. What is the process of defining more than one method in a class differentiated by method signature?

a) Function overriding

b) Function overloading

c) Function doubling

d) None of the mentioned

 

64. Which of the following is a method having same name as that of it’s class?

a) finalize

b) delete

c) class

d) constructor

 

65. Which method can be defined only once in a program?

a) main method

b) finalize method

c) static method

d) private method

 

66. Which of these class is superclass of String and StringBuffer class?

a) java.util

b) java.lang

c) java.sql

d) java.io

 

67. Which of these operators can be used to concatenate two or more String objects?

a) +

b) +=

c) &

d) ||

 

68. Which of this method of class String is used to obtain a length of String object?

a) get()

b) Sizeof()

c) lengthof()

d) length()

69. Which of these method of class String is used to extract a single character from a String object?

a) CHARAT()

b) chatat()

c) charAt()

d) ChatAt()

 

70. Which of these constructors is used to create an empty String object?

a) String()

b) String(void)

c) String(0)

d) String

 

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

a) class B + class A {}

b) class B inherits class A {}

c) class B extends A {}

d) class B extends class A {}

 

72. What is not type of inheritance?

a) Single inheritance

b) Double inheritance

c) Hierarchical inheritance

d) Multiple inheritance

 

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

a) Interfaces

b) Multithreading

c) Protected methods

d) Private methods

 

74. All classes in Java are inherited from which class?

a) java.lang.class

b) java.class.inherited

c) java.class.object

d) java.lang.Object

 

75. In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?

a) Protected

b) Private

c) Public

d) Static

76.  From the following statements which is a disadvantage of an java array?

a. An array can hold primitive types data
b. An array has its size that is known as array length
c. An array knows only its type that it contains. Array type is checked at the compile-time
d. An array holds only one type of data


77.The following Syntax is used for?

class Subclass-name extends Superclass-name
{
//methods and fields
}


a. Polymorphism
b. Encapsulation
c. Inheritance
d. None of the above

 78. Which constructor creates an empty string buffer with the specified capacity as length.

a. StringBuffer()
b. StringBuffer(String str)
c. StringBuffer(int capacity)
d. None of the above

79. If you are inserting any value in the wrong index as shown below,

1. int a[]=new int[5];
2. a[10]=50;

it would result in ______.



a. NullPointerException
b. ArrayIndexOutOfBoundsException
c. ArithmeticException
d. NumberFormatException

80. The following program is an example of?

class Simple{
public static void main(String args[]){

String s="sunita";
System.out.println(s.length());//6
}
}



a. length() method
b. intern() method
c. trim() method
d. charAt() method

81.Breaking a string or stream into meaningful independent words is known as String Tokenization.


a. True
b. False


 82. Which variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed?


a. Local variables
b. Instance variables
c. Class Variables
d. Static variables

83. The Object class is not a parent class of all the classes in java by default.


a. True
b. False

 84. Which access specifiers can be used for a class so that it’s members can be accessed by a different class in the different package?


a. Private
b. Public
c. Protected
d. None of the above

85. Which is a mechanism where one object acquires all the properties and behaviors of the parent object?


a. Inheritance
b. Encapsulation
c. Polymorphism
d. None of the above

86.Which is a technique in Java in which a class can have any number of constructors that differ in parameter lists?


a. Constructor overloading
b. Method overloading
c. Operator overloading
d. None of the above

87. What output you will get if you run this program?
class Modulus {
public static void main(String args[]) {
int x = 42;
double y = 42.25;
System.out.println("x mod 10 = " + x % 10);
System.out.println("y mod 10 = " + y % 10);
}
}



a. x mod 10 = 2
y mod 10 = 2.25
b. x mod 10 = 4
y mod 10 = 2.50
c. x mod 10 = 6
y mod 10 = 3.25
d. x mod 10 = 2
y mod 10 = 4.25

88. Multiple inheritances is not supported in case of class but it is supported in case of interface.


a. True
b. False

89. By interface, we cannot support the functionality of multiple inheritances.

a. True
b. False

90. What type of constructor is used to provide different values to the distinct objects?


a. Default constructor
b. Parameterized constructor
c. Overloading constructor
d. None of the above

91. JVM stands for?

a. Java Very Large Machine
b. Java Verified Machine
c. Java Very Small Machine
d. Java Virtual Machine

92.Which keyword is used by classes to implement an interface?

a. import
b. implements
c. instance of
d. None of the above

93.Who is also called father of Java Programming Language?

a. James Gosling
b. Ken Thompson
c. Dennis Richie
d. None of the above

94. What is the advantage of Method Overloading?

a. Method overloading increases the readability of the program
b. Method overloading does not increases the readability of the program
c. Method overloading does not increases the reliability of the program
d. None of the above

95. Which type of inheritance one super-class have more than one sub-class?

a. Hierarchical inheritance
b. Single inheritance
c. Multiple inheritances
d. Multilevel inheritance

96. If a subclass has the same method as declared in the parent class it is known as ______.

a. Method overriding
b. Method overloading
c. Constructor overloading
d. None of the above

97. If there is no constructor in a class, compiler automatically creates a default constructor.

a. True
b. False

98. Which is nothing but a blueprint or a template for creating different objects which defines its properties and behaviours?


a. An Array
b. A class
c. Interface
d. None of the above

99. Which type of polymorphism is nothing but the method overloading in java?


a. Compile time polymorphism
b. Runtime polymorphism
c. Static polymorphism
d. Both A & C

100. Which class cannot be instantiated?

a. Abstract Class
b. Static Class
c. Both A & B
d. None of the above

101. Which method cannot be overridden?

a. Final Method
b. Final class
c. Final Variable
d. Both A & C

102. Which is a perfect example of runtime polymorphism?

a. Method overloading
b. Method overriding
c. Constructor overloading
d. None of the above

 UNIT 2

1. When does Exceptions in Java arises in code sequence?

a) Run Time

b) Compilation Time

c) Can Occur Any Time

d) None of the mentioned

 

2. Which of these keywords is not a part of exception handling?

a) try

b) finally

c) thrown

d) catch

 

3. Which of these keywords must be used to monitor for exceptions?

a) try

b) finally

c) throw

d) catch

 

4. Which of these keywords must be used to handle the exception thrown by try block in some rational manner?

a) try

b) finally

c) throw

d) catch

 

5. Which of these keywords is used to manually throw an exception?

a) try

b) finally

c) throw

d) catch

 

6. What requires less resources?

a) Thread

b) Process

c) Thread and Process

d) Neither Thread nor Process

 

7. What does not prevent JVM from terminating?

a) Process

b) Daemon Thread

c) User Thread

d) JVM Thread

 

8. What decides thread priority?

a) Process

b) Process scheduler

c) Thread

d) Thread scheduler

 

9. What is true about time slicing?

a) Time slicing is OS service that allocates CPU time to available runnable thread

b) Time slicing is the process to divide the available CPU time to available runnable thread

c) Time slicing depends on its implementation in OS

d) Time slicing allocates more resources to thread

 

10. What should not be done to avoid deadlock?

a) Avoid using multiple threads

b) Avoid hold several locks at once

c) Execute foreign code while holding a lock

d) Use interruptible locks

 

11. What is true about threading?

a) run() method calls start() method and runs the code

b) run() method creates new thread

c) run() method can be called directly without start() method being called

d) start() method creates new thread and calls code written in run() method

 

12. Which of the following is a correct constructor for thread?

a) Thread(Runnable a, String str)

b) Thread(int priority)

c) Thread(Runnable a, int priority)

d) Thread(Runnable a, ThreadGroup t)

 

13. Which of the following stops execution of a thread?

a) Calling SetPriority() method on a Thread object

b) Calling notify() method on an object

c) Calling wait() method on an object

d) Calling read() method on an InputStream object

 

14. Which of the following will ensure the thread will be in running state?

a) yield()

b) notify()

c) wait()

d) Thread.killThread()

 

15. Which of these stream contains the classes which can work on character stream?

a) InputStream

b) OutputStream

c) Character Stream

d) All of the mentioned

 

16. Which of these class is used to read characters in a file?

a) FileReader

b) FileWriter

c) FileInputStream

d) InputStreamReader

 

17. Which of these method of FileReader class is used to read characters from a file?

a) read()

b) scanf()

c) get()

d) getInteger()

 

18. Which of these class can be used to implement the input stream that uses a character array as the source?

a) BufferedReader

b) FileReader

c) CharArrayReader

d) FileArrayReader

 

19. Which of these classes can return more than one character to be returned to input stream?

a) BufferedReader

b) Bufferedwriter

c) PushbachReader

d) CharArrayReader

 

20. Which of these package contains classes and interfaces for networking?

a) java.io

b) java.util

c) java.net

d) java.network

 

21. Which of these is a protocol for breaking and sending packets to an address across a network?

a) TCP/IP

b) DNS

c) Socket

d) Proxy Server

 

22. How many ports of TCP/IP are reserved for specific protocols?

a) 10

b) 1024

c) 2048

d) 512

 

23. How many bits are in a single IP address?

a) 8

b) 16

c) 32

d) 64

 

24. Which of these is a full form of DNS?

a) Data Network Service

b) Data Name Service

c) Domain Network Service

d) Domain Name Service

 

25. Which of these class is used to encapsulate IP address and DNS?

a) DatagramPacket

b) URL

c) InetAddress

d) ContentHandler


26. Unchecked exceptions are checked at compile-time rather they are checked at runtime.


a. True

b. False

 27. Which mechanism is used when a thread is paused running in its critical section and another thread is allowed to enter (or lock) in the same critical section to be executed?

a. Inter-thread communication
b. Initial-thread communication
c. Mutual Exclusive
d. None of the above

28. 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

29. Mutual exclusive and inter-thread communication are which type of Synchorization?

a. Thread Synchronization
b. Process Synchronization
c. Object Synchronization
d. None of the above

30. Which is irrecoverable?

a. Error
b. Checked Exception
c. Unchecked Exception
d. Both B & C

31. Which Exception occurs when a class is not found while dynamically loading a class using the class loaders?


a. ClassNotFoundException
b. ClassFoundException
c. NoClassDefFoundError
d. ClassDefFoundError


32.Classes in the same package cannot access each other's package-access members.

a. True
b. False

33. Which is used to separate the hierarchy of the class while declaring an import statement?


a. Package
b. Applet
c. Browser
d. All of the above

34.The following program is an example for?

class Student{
int id;
String name;

void display(){System.out.println(id+" "+name);}

public static void main(String args[]){
Student s1=new Student();
Student s2=new Student();
s1.display();
s2.display();
}
}



a. Parameterized constructor
b. Default Constructor
c. Overloading Constructor
d. None of the above

35. These two ways

By extending Thread class
By implementing Runnable interface.

are used to?


a. Joining a thread
b. Naming a thread
c. Create a thread
d. sleeping a thread

36. The following exceptions:

NullPointerException,
ArrayIndexOutOfBoundsException,
ArithmeticException,
NumberFormatException

are seen in _______


a. Checked exception
b. Unchecked exception
c. Both A & B
d. None of the above

37. Exception Handling is a mechanism to handle runtime errors

a. True
b. False

38. The life cycle of the thread is controlled by ?

a. JVM
b. JDK
c. JRE
d. None of the above

 UNIT 3

 

1. Which of these packages contains all the classes and methods required for even handling in Java?

a) java.applet

b) java.awt

c) java.event

d) java.awt.event

 

2. What is an event in delegation event model used by Java programming language?

a) An event is an object that describes a state change in a source

b) An event is an object that describes a state change in processing

c) An event is an object that describes any change by the user and system

d) An event is a class used for defining object, to create events

 

3. Which of these methods are used to register a keyboard event listener?

a) KeyListener()

b) addKistener()

c) addKeyListener()

d) eventKeyboardListener()

 

4. Which of these methods are used to register a mouse motion listener?

a) addMouse()

b) addMouseListener()

c) addMouseMotionListner()

d) eventMouseMotionListener()

 

5. What is a listener in context to event handling?

a) A listener is a variable that is notified when an event occurs

b) A listener is a object that is notified when an event occurs

c) A listener is a method that is notified when an event occurs

d) None of the mentioned

 

6. Event class is defined in which of these libraries?

a) java.io

b) java.lang

c) java.net

d) java.util

 

7. Which of these methods can be used to determine the type of event?

a) getID()

b) getSource()

c) getEvent()

d) getEventObject()

 

8. Which of these class is super class of all the events?

a) EventObject

b) EventClass

c) ActionEvent

d) ItemEvent

 

9. Which of these events will be notified if scroll bar is manipulated?

a) ActionEvent

b) ComponentEvent

c) AdjustmentEvent

d) WindowEvent

 

10. Which of these events will be generated if we close an applet’s window?

a) ActionEvent

b) ComponentEvent

c) AdjustmentEvent

d) WindowEvent

 

11. Which of these packages contains all the event handling interfaces?

a) java.lang

b) java.awt

c) java.awt.event

d) java.event

 

12. Which of these interfaces handles the event when a component is added to a container?

a) ComponentListener

b) ContainerListener

c) FocusListener

d) InputListener

 

13. Which of these interfaces define a method actionPerformed()?

a) ComponentListener

b) ContainerListener

c) ActionListener

d) InputListener

 

14. Which of these interfaces define four methods?

a) ComponentListener

b) ContainerListener

c) ActionListener

d) InputListener

 

15. Which of these interfaces define a method itemStateChanged()?

a) ComponentListener

b) ContainerListener

c) ActionListener

d) ItemListener

 

17. Which of these methods will be invoked if a character is entered?

a) keyPressed()

b) keyReleased()

c) keyTyped()

d) keyEntered()

 

18. Which of these methods is defined in MouseMotionAdapter class?

a) mouseDragged()

b) mousePressed()

c) mouseReleased()

d) mouseClicked()

 

19. Which of these is a superclass of all Adapter classes?

a) Applet

b) ComponentEvent

c) Event

d) InputEvent

 

20. Which of the following class is derived from the container class?

  a) Component                   

  b) Panel

  c) MenuComponent               

  d) List

 

 21.Name of the class used to represent a GUI application window, which is optionally resizable and can have a title bar, an icon, and menus.

  a)Window                          

b)Panel

 c)Dialog                        

 d)Frame

 

22.Which abstract class is the super class of all menu related classes?

  a) MenuComponent        

  b )MenuBar

  c )MenuItem             

  d) CheckboxMenuItem

 

23. Which of the following is the default Layout Manager ?

a) FlowLayout

b) BorderLayout

c)GridLayout

d)CardLayout

 

24. How do you change the current layout manager for container?

A.  use setLayout() 

B.  once created you cannot change it 

C.  You set setLayoutManager() 

D.  use updateLayout() 

 

25. AWT components are

A) lightweight

B) heavyweight

C) equalweight

D) weightless

 

26. Which of these packages contain all the collection classes?

a) java.lang

b) java.util

c) java.net

d) java.awt

 

27. Which of these classes is not part of Java’s collection framework?

a) Maps

b) Array

c) Stack

d) Queue

 

28. Which of this interface is not a part of Java’s collection framework?

a) List

b) Set

c) SortedMap

d) SortedList

 

29. Which of these methods deletes all the elements from invoking collection?

a) clear()

b) reset()

c) delete()

d) refresh()

 

30. What is Collection in Java?

a) A group of objects

b) A group of classes

c) A group of interfaces

d) A group of array

 

 31. Which is used for reading streams of raw bytes such as image data and for reading streams of characters, consider using FileReader?

a. FileInputStream
b. FileOutputStream
c. Both A & B
d. None of the above

32.  Which package is used for GUI?


a. java.lang
b. java.awt
c. java.lang.ref
d. java.io

 

CORE JAVA MCQs with Answer CORE JAVA MCQs with Answer Reviewed by Asst. Prof. Sunita Rai, Computer Sci.. Dept., G.N. Khalsa College, Mumbai on December 07, 2020 Rating: 5

No comments:

Powered by Blogger.