0% found this document useful (0 votes)
240 views

JAVA Unit-2 Question Bank

This document contains 25 questions related to Java concepts like constructors, command line arguments, wrapper classes, strings, arrays, and vectors. The questions cover defining and explaining these concepts, providing examples of how to use them, and writing programs to demonstrate various operations involving these data types and classes.

Uploaded by

Amaan Shaikh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
240 views

JAVA Unit-2 Question Bank

This document contains 25 questions related to Java concepts like constructors, command line arguments, wrapper classes, strings, arrays, and vectors. The questions cover defining and explaining these concepts, providing examples of how to use them, and writing programs to demonstrate various operations involving these data types and classes.

Uploaded by

Amaan Shaikh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Unit-2 Question Bank

1) What are the types of constructors? (Winter 15, summer 16,


summer 18) 4 marks

2) What is constructor? Describe the use of parameterized


constructor with suitable example. (Winter 15) 4 marks

3) Define constructor. Explain parameterized constructor with


example. (Summer 16) 4 marks

4) Explain command line arguments.

5) Write a program to accept a number as command line


argument and print the number is even or odd.
(Summer 15) 4 marks

6) Write a program to accept two numbers as command line


arguments and print the addition of those numbers.
(Summer 17) 4 marks

7) Write a program to accept number from command line and


print square root of the number. (Winter 17) 4 marks

8) How garbage collection is done in Java? Which methods are


used for it?. (Winter 16) 4 marks

9) What is garbage collection in Java? Explain finalize method in


Java. (Summer 17) 6 marks

10) What are the access control parameters? Explain the


concept with suitable example. (Winter 16) 6 marks

11) Describe access control specifiers with example.


(Winter 17) 4 marks

12) Perform following string/ string buffer operations, write


java program.
(i) Accept a password from user
(ii) Check if password is correct then display “Good”, else
display “Wrong”
(iii) Display the password in reverse order.
(iv) Append password with “welcome”
(Winter 16) 4 marks

13) Write a program to implement a vector class and its


method for adding and removing elements. After remove
display remaining list. (Summer 16) 8 marks

14) Write a program to add 2 integer, 2 string and 2 float


objects to a vector. Remove element specified by user and
display the list. (Summer 17) 8 marks

15) What is Add element() and Element at() command in


vectors.

16) Define wrapper class. Give the following wrapper class


methods with syntax and use
I. To convert integer number to string
II. To convert numeric string to integer number
III. To convert object numbers to primitive numbers
using type value() method

17) What is the use of wrapper classes in java? Explain float


wrapper with its methods?

18) Describe The following string class methods with


examples:
i. length()
ii. CharAt()
iii. CompareTo()
(Winter 15) 6 marks
19) Compare string class and StringBuffer class with anyfour
points. (Summer 15) 4 marks

20) Explain the following methods of string class with


syntax and example:
(i) substring()
(ii)replace()
(Summer 17) 4 marks

21) Describe following string class method with example:


(i) compareTo( )
(ii) equalsIgnoreCase( )
(Winter 17) 4 marks

22) Write a java program to implement following functions of


string:
(1) Calculate length of string
(2) Compare between strings
(3) Concatenating strings
(Summer 18) 6 marks

23) Differentiate vector and array with any 4 points.


(Summer 15) 4 marks

24) What is difference between array and vector? Explain


elementAt( ) and addElement( ) method. (Winter 15) 4 marks

25) Explain following methods of vector class:


elementAt ()
addElement ()
removeElement ()
(Summer 15) 6 marks

You might also like