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 1: Programming Assignment 1
Complete the code segment to help Ragav, find the highest mark and average mark secured by him in "s" number of subjects.
Solution :
//Initialize a variable to store the highest mark
int highestMark = arr[0];
//Initialize a variable to store the total marks
int totalMarks = 0;
//Iterate through the array to find the highest mark and total marks
for(i=0;i<arr.length;i++)
{
if(arr[i] > highestMark)
{
highestMark = arr[i];
}
totalMarks += arr[i];
}
//Calculate the average mark
mark_avg = totalMarks/s;
//Print the highest mark and average mark
System.out.println(highestMark);
System.out.println(mark_avg); |
Week 1: Programming Assignment 2
Consider First n even numbers starting from zero(0). Complete the code segment to calculate sum of all the numbers divisible by 3 from 0 to n. Print the sum.
Example:
Input: n = 5
-------
0 2 4 6 8
Even number divisible by 3:0 6
sum:6
Solution :
//Iterate through the first n even numbers starting from 0
for(int i=0; i<=n*2; i+=2) {
//Check if the number is divisible by 3
if(i%3 == 0) {
//If divisible, add it to the sum
sum += i;
}
}
//Print the sum of all the numbers divisible by 3
System.out.println(sum); |
Week 1: Programming Assignment 3
Complete the code segment to find the perimeter and area of a circle given a value of radius.
You should use Math.PI constant in your program. If the radius is zero or less than zero then print " please enter non zero positive number ".
Solution :
if(radius<=0)
{
System.out.println("please enter non zero positive number ");
}
else
{
perimeter = 2 * Math.PI * radius;
area = Math.PI * radius * radius;
System.out.println(perimeter);
System.out.println(area);
} |
Week 1: Programming Assignment 4
Complete the code segment to check whether the number is an Armstrong number or not.
Armstrong Number:
A positive number is called an Armstrong number if it is equal to the sum of cubes of its digits for example 153 = 13+53+33, 370, 371, 407, etc.
Solution :
int temp=n;
int c=0,t;
//Use while loop to check the number is Armstrong or not.
while(n>0)
{
t=n%10;
n=n/10;
c=c+(t*t*t);
}
if(temp==c)
result=1;
else
result=0;
//Evaluation code
System.out.println(result); |
Week 1: Programming Assignment 5
Complete the code segment to find the largest among three numbers x,y, and z. You should use the if-then-else construct in Java.
Solution :
if(x >= y && x >= z)
{
result=x;
}
else if(y >= z)
{
result=y;
}
else
{
result=z;
}
//Evaluation code
System.out.println(result); |
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