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

Java Assingment1

1. The document outlines an assignment on Java programming that includes explaining keywords like final, abstract, and static. It also asks to differentiate concepts like throw/throws and call by value/reference as well as compile time and runtime polymorphism. 2. Students are asked to find errors in code snippets and write the expected output if the code is correct. Examples include if/else statements, switch statements, exception handling, and calculating averages. 3. The assignment concludes with tasks to create overloaded addition functions and use inheritance and polymorphism to represent 2D and 3D shapes like circles and spheres.

Uploaded by

Bhanu Gill
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Java Assingment1

1. The document outlines an assignment on Java programming that includes explaining keywords like final, abstract, and static. It also asks to differentiate concepts like throw/throws and call by value/reference as well as compile time and runtime polymorphism. 2. Students are asked to find errors in code snippets and write the expected output if the code is correct. Examples include if/else statements, switch statements, exception handling, and calculating averages. 3. The assignment concludes with tasks to create overloaded addition functions and use inheritance and polymorphism to represent 2D and 3D shapes like circles and spheres.

Uploaded by

Bhanu Gill
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment No. 1 MCA Java Programming, Paper No.

205 IIIrd semester 2011-2012 Jagan Institute of Management Studies Deadline:- 20th sept 2011 1. Explain the usage of each of the following keywords. a) Final b) Abstract c) Static d) Finalize e) super 2. Differentiate between the following with examples. a) throw and throws b) call by value and call by reference c) Compile time polymorphism and Run time polymorphism 3. What is the error in the following programs? Write output if correct. a) public class ABC { public static void main(String[] args) { if (true) if(false) System.out.println("a"); else System.out.println("b found"); } } b) public class XYZ { public static void main(String[] args) { int x; switch(x) { case 2: case 1: case 0: default: case 4:

} } c) Class test { public static void main(String []args) { try { double x=0.0; throw new exception(Thrown); } catch(Exception e) { System.out.println(Exception caught+e); } finally { System.out.println(finally); } } } d) public class test { public static void main(String[] args) { int a1=18; int a2=35; int a3=50; int a4=44; double avg=(a1+a2+a3+a4)/4; System.out.println(avg); } } 4. Create a class named Addition having the following overloaded functions: int add(int , int) double add(double, double) String add(String, String) int add(int []) 5. Design an abstract class named Figure to represent any 2D figure. Inherit this class to represent the class representing Circle. Further, inherit the class circle to represent a 3D figure, sphere. Include Run time polymorphism through the functions to calculate area and perimeter of the figures

You might also like