0% found this document useful (0 votes)
104 views31 pages

Unit 1: Question Bank Class:-Sycs (Sem-Iii) SUBJECT:-Core Java

The document contains a question bank with 63 multiple choice questions related to the Core Java subject for SYCS semester 3 students. The questions cover topics like data types, operators, control flow statements, arrays, OOP concepts, classes and objects. Sample questions include the range of primitive data types like short, byte, etc. and operators like increment, logical AND, and bitwise operators. The document tests knowledge of basic Java programming concepts.

Uploaded by

Swati
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
104 views31 pages

Unit 1: Question Bank Class:-Sycs (Sem-Iii) SUBJECT:-Core Java

The document contains a question bank with 63 multiple choice questions related to the Core Java subject for SYCS semester 3 students. The questions cover topics like data types, operators, control flow statements, arrays, OOP concepts, classes and objects. Sample questions include the range of primitive data types like short, byte, etc. and operators like increment, logical AND, and bitwise operators. The document tests knowledge of basic Java programming concepts.

Uploaded by

Swati
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 31

QUESTION BANK

CLASS:-SYCS(SEM-III) SUBJECT:- Core Java

Unit 1

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

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

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

You might also like