Java Programming Fundamentals
Covers core Java concepts including String manipulation, collections, exceptions, AWT/Swing components, events, and graphics programming
Questions
Which of the following methods cannot be used with the object of String class?
- replace(char, char)
- replaceAll(String, String)
- append(String)
- Both the options 1 and 2
- All of these
What will be result of the given code?
String s1 = “abc”; String s2= “abg”; S1.compareTo(s2);
- - 4
- 4
- - 1
- 1
- 0
What will be returned by the function capacity()?
StringBuffer s = new StringBuffer(“Hello”); s.capacity();
- 16
- 4
- 18
- 3
- 15
What will be the output of the given code segment?
StringBuffer s = new StringBuffer(�Welcome To Java�);
s.delete(8,12);
- Welcome ava
- Welcome va
- Welcomeava
- Compiler error : delete cannot be used with StrinBuffer
- Run time error
Which of the following methods are provided by the Character class?
- isDigit()
- isLetter()
- isLetterOrDigit()
- All of these
- None of these
Which of the following functions are valid in Java for Strings?
- valueOf()
- toCharArray()
- toIntArray()
- Both the options 1 and 2
- Both the options 1 and 3
Which of the following data types can be passed, as the first parameter to the lastIndexOf() method in String class?
- Char
- String
- Int
- Both the options 1 and 2
- All of above
What will be the output of given code?
String s = “Welcome To Java”; s.length(); s.charAt(9);
- s.length() = 14s.charAt(9) = T
- s.length() = 15s.charAt(9) = o
- s.length() = 15s.charAt(9) = T
- s.length() = 14s.charAt(9) = o
- Compiler Error
What will be the answer of the given code?
String s = “Welcome To Java” s.substring(4 , 4 );
- 0
- c
- Empty string
- Compile time error
- Run time error
Which of the following are not the methods of the scanner class object in java?
- Next()
- nextLine()
- nextInt()
- nextChar()
- nextLong()
Which of the following methods is/are used by web browser to control the applet?
- Wait()
- Destroy()
- Dead()
- Both the options 1 and 3
- Both the options 1 and 2
Which of the following are the Subclasses of RuntimeException?
- IllegalArgumentException
- NullPointerException
- IOException
- IndexOutOfBoundException
- ArithmeticException
Which of the following event types are invalid in JAVA?
- FocusEvent
- ComponentEvent
- AdjustmentEvent
- Both the option 2 and 3
- None of these
What is the result of the given statements?
String s = “Welcome To Java” s.lastIndexOf(“Java”,5);
- - 1
- 11
- 6
- Compiler error : method lastIndexOf() not declared.
- Compiler error : parameters to method not sufficient.
Which of following layout managers are present in java awt?
- Gridlayout
- Flowlayout
- Cardlayout
- Both the options 1 and 2
- All of these
How many primitive data types are available in Java?
- 9
- 6
- 8
- 7
- 5
How many constructors are there for Layout manager FlowLayout?
- 5
- 4
- 3
- 2
- 1
Which of the following methods cannot be invoked from the instance of Frame class in AWT?
- setLocation(int, int)
- setVisible(Boolean)
- setSize(int, int)
- setSize(int, int)
- Pack()
Which of the following methods is valid in Java for handling Events?
- mouseEnetered()
- keyReleased()
- mouseDragged()
- Both the options 1 and 2
- All of these
Which of the following methods is/are not necessary to define for a class if it implement the windowListener Interface?
- windowMoved()
- windowClosing()
- windowIconified()
- windowActivated()
- windowDeiconified()
How many constructors are present of BorderLayout in Java?
- 5
- 4
- 3
- 2
- 1
Which of the following statements is/are correct?
Color c1 = new Color(284,60,189);
- A new colour will be created.
- runtime Exception
- Parameters are not enough
- Compile time error; cannot find method colour.
- Compile time error; colour is Abstract cannot create an object.
How many parameters are passed to the constructor of the Font class in java?
- 4
- 3
- 2
- 1
- None of these
Which of the following sources object do not generate the ActionEvent?
- JRadioButton
- JCheckBox
- JComboBox
- JList
- JTextField
Which of the following methods is not defined in the Graphics Class in java?
- fillRect()
- fillCircle()
- fillOval()
- fillArc()
- None of these