Programming In Java
With the growth of Information and Communication Technology, there is a need to develop large and complex software. Further, those software should be platform independent, Internet enabled, easy to modify, secure, and robust. To meet this requirement object-oriented paradigm has been developed and based on this paradigm the Java programming language emerges as the best programming environment. Now, Java programming language is being used for mobile programming, Internet programming, and many other applications compatible to distributed systems. This course aims to cover the essential topics of Java programming so that the participants can improve their skills to cope with the current demand of IT industries and solve many problems in their own filed of studies.
PREREQUISITES : This course requires that the students are familiar with programming language such as C/C++ and data structures, algorithms.
INDUSTRY SUPPORT : All IT companies.
Nptel Programming in Java Week 2 Assignment Answers
Course layout
Nptel Programming in Java Week 2 Assignment Answers
Week 2 Assignment 2
Nptel Programming in Java Week 2 answers
// Create a Student object and call displayInfo
// Add the necessary code in the spaces below
//done enjoy
//code to create student object
Student student = new Student(name,age,grade);
//code to call displayInfo function
student.displayInfo();
Java week 2 Question 2 code
// Write the appropriate constructor call code in the given spaces .
//Good luck
if (grade == null ||grade.isEmpty()) {
student = new Student(name,age); // Add your code to call the constructor when grade is not given in input
} else {
student = new Student(name,age,grade); // Add your code to call the constructor when grade is given in input
}
// code to call displayInfo function to display the information
student.displayInfo(); // Call the displayInfo method to display the student’s information
Java week 2 Question 3 code
// Define the class Rectangle here
// Use the this keyword in the constructor
// Define the area method
class Rectangle {
int length, breadth;
// Constructor
Rectangle(int length, int breadth) {
this.length = length;
this.breadth = breadth;
}
// Method to calculate area
int area() {
return length * breadth; //write the correct formula
}
}
//I hope it will work
Java week 2 Question 4 code
// Define the class Car here
// Write a constructor and a display method
//ok
class Car {
//variables
String brand;
int price;
// Constructor
Car(String brand,int price) {
this.brand=brand;
this.price=price;
}
// Display method
void display(int num) {
System.out.println(“Car ” + num + “: ” + brand + “, Price: ” + price);
}
}
Java week 2 Question 5 code
//Let us see
class Book {
// Private attributes
private String title;
private String author;
// Setter for title
public void setTitle(String title) {
this.title = title;
}
// Setter for author
public void setAuthor(String author) {
this.author=author;
}
// Getter for title
public String getTitle() {
return this.title;
}
// Getter for author
public String getAuthor() {
return this.author;
}