186k views
3 votes
In ________ for final fields and methods the value is assignedlater but in ______ you assign the value during declaration.

Java , C++
C++ , C#
Java , C#
C++ ,Java

2 Answers

1 vote

Answer:

The answer to this question is Java,C++.

Step-by-step explanation:

We can assign non static final variables a value with the declaration or in the constructor but this is not the case with c++ because we have to assign value during declaration and c++ equivalent of final is const keyword and there is sealed or readonly keywords in c# not final.If we do not assign value at the time of declaration the const variable will contain garbage value which cannot be changed afterwards.

User Ling Vu
by
7.8k points
4 votes

Answer:

The answer to this question is Java,C++.

Step-by-step explanation:

We can assign non static final variables a value with the declaration or in the constructor but this is not the case with c++ because we have to assign value during declaration and c++ equivalent of final is const keyword and there is sealed or readonly keywords in c# not final.If we do not assign value at the time of declaration the const variable will contain garbage value which cannot be changed afterwards.

User Besnik
by
8.2k points