What is Programming in Java?
Java is a popular object-oriented programming language that was first released in 1995. It is used for developing a wide range of applications, including desktop applications, mobile applications, web applications, and enterprise applications.
Here are some key features and concepts of Java programming:
Object-oriented programming: Java is an object-oriented language, which means that it focuses on the creation of objects that contain both data and methods that operate on that data.
Platform independence: Java programs can run on any platform that supports a Java Virtual Machine (JVM), which makes it a popular choice for cross-platform development.
Memory management: Java uses automatic memory management through a garbage collector, which helps to prevent memory leaks and makes it easier to write memory-safe code.
Exception handling: Java has a built-in mechanism for handling runtime errors or exceptions, which helps to ensure that programs can recover gracefully from unexpected errors.
Multi-threading: Java supports multi-threading, which allows programs to execute multiple threads of execution simultaneously, making it well-suited for developing concurrent applications.
Standard libraries: Java provides a large number of standard libraries that developers can use to build applications more quickly and easily, including libraries for networking, database access, and user interface development.
To get started with Java programming, you will need to install the Java Development Kit (JDK) on your computer. Once you have installed the JDK, you can use an Integrated Development Environment (IDE) like Eclipse or IntelliJ IDEA to write and debug your code.
To learn Java programming, you can start with the basics of the language, such as data types, control structures, and object-oriented programming concepts. There are many online resources and tutorials available for learning Java, including Oracle's official Java tutorials, which cover everything from the basics to advanced topics like concurrency and networking.
Week 3 : Programming Assignment 1
Due on 2023-02-16, 23:59 ISTDefine a class Point with two fields x and y each of type double. Also, define a method distance(Point p1, Point p2) to calculate the distance between points p1 and p2 and return the value in double.
Complete the code segment given below. Use Math.sqrt( ) to calculate the square root.
Solution :
class Point{
double x;
double y;
public static void distance(Point p1,Point p2){
double d;
d=Math.sqrt((p2.x-p1.x)*(p2.x-p1.x) + (p2.y-p1.y)*(p2.y-p1.y));
System.out.println(d);
}
}
Define a class Point with two fields x and y each of type double. Also, define a method distance(Point p1, Point p2) to calculate the distance between points p1 and p2 and return the value in double.
Complete the code segment given below. Use Math.sqrt( ) to calculate the square root.
Solution :
class Point{
double x;
double y;
public static void distance(Point p1,Point p2){
double d;
d=Math.sqrt((p2.x-p1.x)*(p2.x-p1.x) + (p2.y-p1.y)*(p2.y-p1.y));
System.out.println(d);
}
} |
Week 3 : Programming Assignment 2
Due on 2023-02-16, 23:59 ISTThis program to exercise the call of static and non-static methods. A partial code is given defining two methods, namely sum( ) and multiply ( ). You have to call these methods to find the sum and product of two numbers. Complete the code segment as instructed.
Solution :
QuestionScope st = new QuestionScope(); // Create an object to call non-
//static method
int result1=st.sum(n1,n2); // Call the method
int result2=QuestionScope.multiply(n1,n2); // Create an object to call
//static method
System.out.println(result1);
System.out.println(result2);
This program to exercise the call of static and non-static methods. A partial code is given defining two methods, namely sum( ) and multiply ( ). You have to call these methods to find the sum and product of two numbers. Complete the code segment as instructed.
Solution :
QuestionScope st = new QuestionScope(); // Create an object to call non-
//static method
int result1=st.sum(n1,n2); // Call the method
int result2=QuestionScope.multiply(n1,n2); // Create an object to call
//static method
System.out.println(result1);
System.out.println(result2);
|
Week 3 : Programming Assignment 3
Due on 2023-02-16, 23:59 ISTComplete the code segment to swap two numbers using call by object reference.
Solution :
public static void swap(Question t) {
int temp = t.e1;
t.e1 = t.e2;
t.e2 = temp;
}
Complete the code segment to swap two numbers using call by object reference.
Solution :
public static void swap(Question t) {
int temp = t.e1;
t.e1 = t.e2;
t.e2 = temp;
} |
Week 3 : Programming Assignment 4
This program is related to the generation of Fibonacci numbers.>
For example: 0,1, 1,2, 3,5, 8, 13,… is a Fibonacci sequence where 13 is the 8th Fibonacci number.
A partial code is given and you have to complete the code as per the instruction given .
Solution :
if (n==1) //Terminal condition
return 0;
else if(n==2)
return 1;
return fib(n - 1) + fib(n - 2); //Recursive call of function
|
Week 3 : Programming Assignment 5
A class Shape is defined with two overloading constructors in it. Another class Test1 is partially defined which inherits the class Shape. The class Test1 should include two overloading constructors as appropriate for some object instantiation shown in main() method. You should define the constructors using the super class constructors. Also, override the method calculate( ) in Test1 to calculate the volume of a Shape.
Solution :
//Template code:
double height;
Test1(double length,double h) {
//base class constructor with one parameter is called
super(length);
height=h;
}
Test1(double length,double breadth,double h) {
//base class constructor having two argument is called
super(length,breadth);
height=h;
}
double calculate() {
return length*breadth*height;
} |
CRITERIA TO GET A CERTIFICATE
Average assignment score = 25% of the average of the best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100
Final score = Average assignment score + Exam score
YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF THE AVERAGE ASSIGNMENT SCORE >=10/25 AND THE EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.
| Programming in JAVA | Answers |
| Assignment 1 | Click Here |
| Assignment 2 | Click Here |
| Assignment 3 | Click Here |
| Assignment 4 | Click Here |
| Assignment 5 | Click Here |
| Assignment 6 | Click Here |
| Assignment 7 | Click Here |
| Assignment 8 | Click Here |
| Assignment 9 | NA |
| Assignment 10 | NA |
| Assignment 11 | NA |
| Assignment 12 | NA |
Comments
Post a Comment