123343067-Quiz.doc

Private native void m1 a all of them are legal

  • No School
  • AA 1
  • 32

This preview shows page 19 - 23 out of 32 pages.

4.private native void m1(); A. All of them are legal declarations.B. 1 and 3C. 2 and 4D. 1 only Answer Key: A
Image of page 19

Subscribe to view the full document.

# Question 8 of 10 10.0 Points Which three among the following are valid method signatures in an interface? 1.private int getArea(); 2.public float getVol(float x); 3.public void main(String [] args); 4.public static void main(String [] args); 5.boolean setFlag(Boolean [] test); Answer Key: D # Question 9 of 10 10.0 Points Which option among the following creates an instance of an array? Answer Key: A # Question 10 of 10 10.0 Points Which of the following class level (nonlocal) variable declarations will not compile? Answer Key: B TCS ASPIRE : Unix Assignment 1 quiz answers 2012 # Question1: Write a command to list all the files inside a folder i.e. if there is a folder inside a folder then it should list all files inside the sub-folder which is inside the folder to be listed. Answer: ls -aR [Hint] Ls =list information about files. -a –all (hidden files also), -R –recursive (list subdirectories)
Image of page 20
# Question 2: Search all the files which contains a particular string, say “include” within a folder. Answer: grep include ./* [Hint] Grep = searches the named input file for lines containing a match to the given pattern. ./* = In current directory (.), all files(*) # Question 3: Rename all the files within a folder with suffix “Unix_” i.e. suppose a folder has two files a.txt and b.pdf than they both should be renamed from a single command to Unix_a.txt and Unix_b.pdf Answer: for i in *.*;do mv “$i” Unix_”$i”;done; [Hint] Loop: Syntax for variable in no of times; Do command; ….; Done; Here: i= *.* (for all files) $= to read value of variable. do mv “$i” Unix_”$i” = rename *.* as Unix_*.* # Question 4: Rename all files within a folder with the first word of their content(remember all the files should be text files. For example if a.txt contains “Unix is an OS” in its first line then a.txt should be renamed to Unix.txt Answer: for i in *.txt; do head -1 “$i” > ad.txt ; x=”$(cut -d ‘ ‘ -f1 ad.txt)”; mv “$i” “$x.txt”; done; [Hint] i = *.txt (all text files); do head -1 “$i” > ad.txt; = prints first line and store in ad.txt file. x=”$(cut -d ‘ ‘ -f1 ad.txt)” ; = removes first column (field) delimited by space from ad.txt file stores in x. mv “$i” “$x.txt”; = rename *.txt as value of x .txt. # Question 5: Suppose you have a C project in a folder called “project”, it contains .c and .h files, it also contains some other .txt files and .pdf files. Write a Linux command that will count the number of lines of your text files. That means total line count of every file. (remember you have to count the lines in .txt files only)
Image of page 21

Subscribe to view the full document.

Answer: wc –l *.txt [Hint] Here: wc =word count -l =to count lines *.txt =all text files # Question 6: Rename all files which contain the sub-string ‘foo’, replacing it with ‘bar’ within a given folder.
Image of page 22
Image of page 23

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern