BIT 2nd Sem - JAVA Programming, Assignment 2_1724306807565
BIT 2nd Sem - JAVA Programming, Assignment 2_1724306807565
Java Programming
Explore, Learn and Excel
Assignment 2
Theory portion
● Explain the differences between String and StringBuffer classes in Java, and in what
scenarios you should use each one?
● Explain how to convert an object to a string in Java. Explain different access modifiers
with their scope and example.
● Write an immutability concept of String with the help of an example, program, and
diagram.
Note: (Heap Memory and SCP)
Practical Portion
String two
String name
Theory portion
● Explain the concept of Exception Handling in Java and discuss some best
practices for using Exceptions in your code with checked and unchecked
exception.
● Explain try, catch and finally block with example.
● How can you create your own exception? Explain with example.
● Give clear explanation of “throw” and “throws” keyword which are used in
exception handling with example.
Practical Portion
● The following program will generate an error, because myNumbers[5] does not exist.
System.out.println(myNumbers[5]); // error!
}
}
Use try...catch to catch the error and execute some code to handle it:
Theory Portion
Practical Portion
● Write a Java program that reads a text file and counts the number of
words in it. The program should then write the word count to a new file.
Theory Portion
● What is the Java Collection Framework and how do you choose different collections?
Explain Generic in Java.
● Explain scenarios to use Set, List and Map in Java with proper reasons and examples.
Practical Portion
● Write a Java program to create a new array list, add some colors (string) and print
out the collection.
● Write a Java program to create a new priority queue, add some colors (string) and
print out the elements of the priority queue.
Design Pattern
Theory portion
● Explain your understanding in Design Patterns with real life examples and types.
● Give an example of a singleton in java with a proper example.
● Design patterns ease the analysis and requirement phase of SDLC by providing
informationbased on prior hands-on experiences. Explain
Practical portion
Suppose you want to create a class for which only a single instance (or object) should be
createdand that single object can be used by all other classes. Propose a solution for this
problem.