5. Java Concepts (a) Explain what a controller class is and what a model class i
ID: 3595380 • Letter: 5
Question
5. Java Concepts
(a) Explain what a controller class is and what a model class is. Give a specic example.
(b) Understand and explain a simple UML class diagram.
(c) Name a container class.
(d) How do you read a text le and check for end-of-le?
(e) What are command-line arguments? Why are they useful? Where do you write them? How does a Java program get them?
(f) What is the dierence between a text le and an object le? Why do we need object les?
(g) Dene the terms “serialize” and “realize”. What does it mean when you declare a class to be Serializable?
Questions from java programming course,Answer for above questions on basis of java concepts
Explanation / Answer
d.) How do you read a text le and check for end-of-le?
To read the text file in java you need to use FileReader in java. To demonstrate here is the small code on how to go on with it:
FileReader fr = new FileReader("Youfile.txt");
Scanner sc = new Scanner (fr);
To check the end of the file there is the need of this line in the object. To check the end of the file one will be required to go through the following lines. They are as follows:
while(sc.hasNext())
{
String str = sc.nextLine();
System.out.println(str);
}
Hence, this is the way of operating files in java
e.) Command Line Arguments are the commands which are used to carry the same work as done using GUI but here we need to write each time different command for every set of the instrutions given to the computer. The command line arguments are somewhat important as there are many consequences of not using the command l
Java program uses command line arguments such as javac, javap, etc.
As, it is chegg policy to answer only one question per answer. Hence, you'll be required to post rest of the questions and you'll definitely get the answers....Thankyou
Rate an upvote...Thankyou
Hope this helps......
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.