Beruflich Dokumente
Kultur Dokumente
Now invoke both the super-class method and sub-class method with the
help of subclass object only.
Write a program to create a class named Demo which cannot be
inherited and which inherits a class named Test which cannot be
instantiated.
Unit-2
WAP to demonstrate the use of any five methods of ArrayList class. Explain
the output. Also explain use get and set methods present in ArrayList class.
How ArrayList is different from Array in java? Can you add a string and an
integer in the same ArrayList?
What do you mean by Jagged Array? Write code snippet to create Jagged
Array.
WAP to create a two-dimensional array in which dimensions of the array
and array elements are entered by user at run time.
WAP to create a square matrix and initialize it at run time. Now display the
sum of all its elements on the major diagonal using the following method:
String s = "Hello";
String s2 = "Hello";
s1.toUpperCase();
System.out.println("Hello World".compareTo("Hello"));
WAP that prompts the user to enter a String. Write your own method
WAP to prompt the user to enter a String and a character. Write your own
method that counts the occurrences of a given character in a string using
the following header: public static int count(String s, char c)
Ex: count(Hello, l) returns 2.
Wrapper Class
Unit-3
Packages
What do you mean by Package? What is the need of Packages? How will
you restrict the access of a data member outside the package?
Discuss all the access specifiers in Java. Can we define a private class?
WAP to create a class A in package P1 which invokes a non-static method
demo() of another class B of package P2. (Write the code of class A only)
How will you create a class Test in a package named "MyPack"? Write code
snippet only.
Exception Handling