Sign Up

Sign In

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Sorry, you do not have permission to ask a question, You must login to ask a question.

SIKSHAPATH Latest Articles

NPTEL Programming In Java Week 3 Assignment Answers 2023

NPTEL Programming in Java Assignment Answer

Are you looking for help in Programming In Java NPTEL Week 3 Assignment Answers? So, here in this article, we have provided Programming In Java week 3 Assignment Answer’s hint.

Table of Contents

NPTEL Programming In Java Week 3 Assignment Answers

Q1. Which of the following statement(s) is/are correct about the constructor?

Answer: a. Constructors cannot be synchronized in Java.
b. Java does not provide a default copy constructor.

d. “this” or “super” can be used in a constructor.

1000+ students getting help from instant notifications, Join us on telegram.


Q2. Which of the following statement(s) is/are true?

Answer: a. You can write a new instance method in the subclass with the same signature as the one in the superclass, thus overriding it.
b. You can write a new static method in the subclass with the same signature as the one in the superclass, thus hiding it.
c. A subclass inherits all of its parent’s public and protected members, no matter what package the subclass is in.


Q3. Consider the following piece of code.

class Test { 
   void exam () {} 
}
public class Test1 extends Test { 
________void exam () {} // insert correct keyword 
public static void main(String[] args) {    
System.out.println(" Correct");
    }
}

Fill in the blank with the appropriate keyword(s) from the list given below so that the program compiles successfully.

Answer: b. final
d. public


Q4. How many instances of abstract class can be created?

Answer: a. 0


Q5. Structuring a Java class such that only methods within the class can access its instance variables is referred to as _______.

Answer: d. encapsulation


Q6. Which of the following statement(s) is/are true?

Answer: a. A final method cannot be overridden in a subclass.
b. The advantage of private static methods is that they can be reused later if you need to reinitialize the class variable.
c. Class methods cannot use this keyword as there is no instance for this to refer to.


Q7. Consider the following piece of code.

public class Question{ 
Question () { 
this ();
}

public static void main(String[] args) { 
Question obj = new Question (); 
System.out.println("Java");
  }
}

Which of the following is the output of the above program?

Answer: b. There will be a compile-time error.


Q8. Consider the following program.

public class Question
{
public static void main(String[] args) { 
    String str = "Programming in java.";
     System.out.println(str.charAt (4) +str.substring (8, 11));
  }
}

What is the output of the above program?

Answer: b. ring


Q9. Which of the following statement(s) is/are False?

Answer: c. The term “class variable” is another name for a non-static field.


Q10. Which of the following statement(s) is/are true?

Answer: a. Static methods in interfaces are never inherited.
b. You will get a compile-time error if you attempt to change an instance method in the superclass to a static method in the subclass.
c. You can prevent a class from being subclassed by using the final keyword in the class’s declaration.
d. An abstract class can only be subclassed; it cannot be instantiated.

Programming In Java Week 3 Programming Assignment Answers

Q1.

class Point{
  double x;
  double y;

public static void distance(Point p1,Point p2){
        double dis;
	  dis=Math.sqrt((p2.x-p1.x)*(p2.x-p1.x) + (p2.y-p1.y)*(p2.y-p1.y));
	  System.out.println(dis);
  }	
}  

Q2.

QuestionScope stp = new QuestionScope(); 
      int result1=stp.sum(n1,n2); 
      int result2=QuestionScope.multiply(n1,n2);	
                                               
		
		System.out.println(result1);
		System.out.print(result2);

Q3.

public static void swap(Question t) {
int tempo = t.e1;
    t.e1 = t.e2;
    t.e2 = tempo;
  }

Q4.

      if (n==1)      
            return (0);
        else if(n==2)
            return 1; 			
        return (fib(n - 1) + fib(n - 2)); 

Q5.

  double height1;
  Test1(double l,double h)
  {
   super(l);
   this.length = l;
   this.height1 = h;
  }

  Test1(double l,double b,double h)
  {
    super(l,b);
    this.length=l;
    this.breadth=b;
    this.height1=h;
  }

  double calculate()
  {
   return length*breadth*height1; 
  }

TELEGRAM FOR NOTIFICATIONClick Here
Follow on Google News (in one click)Click Here

Disclaimer: These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.


Also Available:

NPTEL Programming In Java Week 2 Assignment Answers

NPTEL Java week 4 assignment answers

Related Posts

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock