Unit 1: Question Bank Class:-Sycs (Sem-Iii) SUBJECT:-Core Java
Unit 1: Question Bank Class:-Sycs (Sem-Iii) SUBJECT:-Core Java
Unit 1
a) -128 to 127
b) -32768 to 32767
c) -2147483648 to 2147483647
d) -5000 TO 5000
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
a) -1.7e+308
b) -3.4e+038
c) +1.7e+308
d) -3.4e+050
a) int
b) float
c) double
d)long
class increment {
int g = 3;
System.out.print(++g * 8);
a) 25
b) 24
c) 32
d) 33
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
b) 0 & 1
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
a) boolean b1 = 1;
b) boolean b2 = ‘false’;
c) boolean b3 = false;
d) boolean b4 = ‘true’
class booloperators {
{
boolean var1 = true;
a) 0
b) 1
c) true
d) false
a) 0x99fffL
b) ABCDEFG
c) 0x99fffa
d) 99671246
a) Integer
b) Boolean
c) Character
d) Integer or Boolean
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
d) constant
a) java.sql.Date
b) java.util.Date
c) java.sql.DateTime
d) java.util.DateTime
class c
a) Hello c
b) Hello
c) Hello world
d) Runtime Error
a) malloc
b) alloc
c) new
d) new malloc
System.out.print(arr);
a) 0
c) 00000
b) Array can be initialized using comma separated expressions surrounded by curly braces
a) Row
b) Column
d) Table
class evaluate
int n = 6;
n = arr[arr[n] / 2];
System.out.println(arr[n] / 2);
a) 3
b) 0
c) 6
d) 1
a) Numeric
b) Boolean
c) Characters
a) Integers
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
class increment
{
int g = 3;
System.out.print(++g * 8);
a) 25
b) 24
c) 32
d) 33
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) >>=
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
c) Boolean
d) Character
37. Which of these operators can skip evaluating right hand operand?
a) !
b) |
c) &
d) &&
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
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.*
d) A package can be renamed without renaming the directory in which the classes are stored
a) if
b) switch
c) if & switch
d) if-else
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?
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
if(1)
System.out.println("OK");
A) OK
B) No output
C) Compiler error
D) Runtime error
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.
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
A) boolean
B) int
C) float
D) char
a) Inheritance
b) Encapsulation
c) Polymorphism
d) Compilation
c) Multiple polymorphism
d) Multilevel polymorphism
a) At run time
b) At compile time
c) At coding time
d) At execution time
a) class
b) struct
c) int
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
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
a) main method
b) finalize method
c) static method
d) private method
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()
a) String()
b) String(void)
c) String(0)
d) String
a) class B + class A {}
c) class B extends A {}
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
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
UNIT 2
a) Run Time
b) Compilation Time
a) try
b) finally
c) thrown
d) catch
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
a) try
b) finally
c) throw
d) catch
a) Thread
b) Process
b) Daemon Thread
c) User Thread
d) JVM Thread
a) Process
b) Process scheduler
c) Thread
d) Thread scheduler
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) 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?
b) Thread(int priority)
d) Thread(Runnable a, ThreadGroup t)
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
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
a) 8
b) 16
c) 32
d) 64
a) DatagramPacket
b) URL
c) InetAddress
d) ContentHandler
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
c) An event is an object that describes any change by the user and system
a) KeyListener()
b) addKistener()
c) addKeyListener()
d) eventKeyboardListener()
a) addMouse()
b) addMouseListener()
c) addMouseMotionListner()
d) eventMouseMotionListener()
a) java.io
b) java.lang
c) java.net
d) java.util
a) getID()
b) getSource()
c) getEvent()
d) getEventObject()
a) EventObject
b) EventClass
c) ActionEvent
d) ItemEvent
b) ComponentEvent
c) AdjustmentEvent
d) WindowEvent
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
a) ComponentListener
b) ContainerListener
c) ActionListener
d) InputListener
14. Which of these interfaces define four methods?
a) ComponentListener
b) ContainerListener
c) ActionListener
d) InputListener
a) ComponentListener
b) ContainerListener
c) ActionListener
d) ItemListener
a) keyPressed()
b) keyReleased()
c) keyTyped()
d) keyEntered()
a) mouseDragged()
b) mousePressed()
c) mouseReleased()
d) mouseClicked()
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
a) FlowLayout
b) BorderLayout
c)GridLayout
d)CardLayout
24. How do you change the current layout manager for container?
A. use setLayout()
D. use updateLayout()
A) lightweight
B) heavyweight
C) equalweight
D) weightless
a) java.lang
b) java.util
c) java.net
d) java.awt
a) Maps
b) Array
c) Stack
d) Queue
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()
a) A group of objects
b) A group of classes
c) A group of interfaces
d) A group of array