Professional Documents
Culture Documents
Programs Under Practice Section
Programs Under Practice Section
1) Generate 100 lowercase letters randomly and assign to an array of characters. Count the
occurrence of each letter in the array.
4. Write a method that takes a 2D matrix as input and calculates the transpose of the matrix.
5. Write a method that takes two 2D matrices of same dimension and calculates their summation.
// A + B
6. Write a method that takes two 2D matrices and calculates their multiplication. // AB
Quiz-2
1. Default Constructor with code example.
A. When we write a class without any constructors, java implicitly provides a public constructor with no
arguments. This constructor is known as the default constructor, which is provided by java if and only if
no other explicit constructors are present in that class.
The following is a default constructor, as no other constructor is written in the class Pizza.
In line 2 , static int a; should be initialised as java does not initialize final constants.
In line 6. ‘b’ is an instance variable and it cannot be referenced to a static context.
In Line 7. Static method f1() cannot invoke a non-static method f2().
In line 12. ‘c’ is a local variable and cannot have modifier. Also int c is already declared in line 12.
In line 14. ‘a’ is a final constant and cannot be accesed to change its value.