Java Programming MCQ’s Questions and Answers
By Team Alpha | General knowledge | Mar 27, 2018
- Which of these operators is used in Java to allocate memory to array variable?
- Malloc
- New
- Alloc
- new malloc
Ans c.(new)
2.Which of these is incorrect array declaration?
- int arr[] arr = new int[5]
- int [] arr = new int[5]
- int arr[] = int [5] new
- int arr[] = new int[5]
Ans c.(int arr[] = int [5] new)
- Which of these class is StringBuffer class and superclass of String?
- lang
- ArrayList
- util
- None of the mentioned
Ans a.(java.lang)
- Which of these method of a class String is used to extract single character from a String object?
- charAt()
- charat()
- ChatAt()
- CHARAT()
Ans c.(CharAt)
- Which of these constructors is used to create empty String object?
- String(0)
- String()
- String(void)
- None of the mentioned
Ans b.(String())
- Which of the following can be operand of arithmetic operator?
- Boolean
- Characters
- Both Boolean & Characters
- Numeric
Ans c.( Both Boolean & Characters)
- Which of these can be applied to modulus operator, %?
- Floating – point numbers
- Integers
- Both Integers and floating – point numbers.
- None of the mentioned
Ans c. (Both Integers and floating – point numbers)
- Decrement operator, –, decreases value of variable by what number?
- 4
- 2
- 3
- 1
Ans d.(1)
- Which of these packages contain all the collection classes?
- net
- util
- awt
- lang
Ans b.( java.util)
- Which of these classes is not part of Java’s collection framework?
- Stack
- Queue
- Maps
- Array
Ans b.(Queue)
- Which of these interface is not a part of Java’s collection framework?
- SortedMap
- List
- SortedList
- Set
Ans c.(SortedList)
- Which of these method delete all the elements from invoking collection?
- reset()
- refresh()
- delete()
- clear()
Ans d.(clear())
- What is a Collection in Java?
- A group of classes
- A group of objects
- A group of interfaces
- None of the mentioned
Ans b.( A group of objects)
- Which of these keywords is used to define a interfaces in Java?
- Intf
- intf
- interface
- Interface
Ans c.( interface)
- Which of these can be used a class from its implementation to fully abstract?
- Packages
- Interfaces
- Objects
- None of the Mentioned
Ans b.(Interfaces)
- AWT stands for?
- All Writing Tools
- Abstract Writing Toolkit
- All Window Tool
- Abstract Window Toolkit
Ans d.( Abstract Window Toolkit)
- Which of these methods is a part of AWT (Abstract Window Toolkit)?
- transient()
- print()
- display()
- drawString()
And b. (print())
- Which of these is static variable defined in Collections?
- EMPTY_MAP
- EMPTY_SET
- EMPTY_LIST
- All of the mentioned
Ans d.(All of the mentioned)
- Which of these methods can randomize all elements in a list?
- randomize()
- rand()
- ambigous()
- shuffle()
Ans d.(shuffle())
- In this which keywords is not a part of exception handling?
- catch
- finally
- try
- thrown
Ans d.( thrown)