File Formats and Extensions: Documents, Images, Audio and Archives

A file extension is the short label after the last dot in a file name, such as .pdf or .mp3, and it tells the operating system what kind of data the file holds and which program should open it. Computer papers often ask which extension belongs to which program, which image format supports animation or transparency, and whether a format is lossy or lossless. Knowing a few dozen common extensions and the idea of compression covers almost every question.

Asked in: PPSC, FPSC, NTS, ETEA, KPPSC, SSC, IBPS and ICS/ECAT computer

What a file extension does

A file name has two parts: the name chosen by the user and the extension after the last dot, as in result.pdf. Windows uses the extension to pick the program and the icon; Windows Explorer can hide known extensions, which is why some users never see them.

Renaming the extension does not convert a file. Changing song.wav to song.mp3 leaves the data unchanged, so programs may refuse to open it. Real conversion needs software that rewrites the data in the new format.

An extension is only a label, so a harmful program can be disguised with a name such as photo.jpg.exe; when extensions are hidden, only photo.jpg shows.

Document and data formats

.txt is plain text with no fonts, colours or images, readable by any editor such as Notepad. .rtf (Rich Text Format) keeps basic formatting and opens in most word processors.

Microsoft Word uses .doc (Word 97-2003) and .docx (Word 2007 onwards); Excel uses .xls and .xlsx, with .xlsm for macro-enabled workbooks; PowerPoint uses .ppt and .pptx. The x formats are XML-based files packed in ZIP compression. LibreOffice and OpenOffice use the OpenDocument formats .odt, .ods and .odp.

.pdf (Portable Document Format), created by Adobe, keeps a document’s layout the same on every device and printer, so forms, papers and e-books are shared as PDF. .csv (comma-separated values) is a plain-text table in which each line is a row and commas separate the columns; Excel and databases can import it, but it keeps no formulas or formatting.

Image formats

.jpg or .jpeg (Joint Photographic Experts Group) uses lossy compression and suits photographs, where small losses are hard to see. .png (Portable Network Graphics) uses lossless compression and supports transparent backgrounds, which suits logos, screenshots and diagrams.

.gif (Graphics Interchange Format) is limited to 256 colours, compresses losslessly and supports simple animation. .bmp is the Windows bitmap, usually stored uncompressed and therefore large. .tif or .tiff is used in printing and scanning, .ico holds Windows icons, and .svg (Scalable Vector Graphics) stores drawings as shapes, so they can be enlarged without blurring.

Audio and video formats

Audio: .mp3 is the most common lossy format; .aac is another lossy format used in many phones and online services; .wav usually stores uncompressed audio and gives large files; .flac is lossless compressed audio, smaller than WAV but with no loss of quality; .mid (MIDI) stores musical notes and instructions rather than recorded sound.

Video: .mp4 is the most widely used video container; others include .avi, .mkv, .mov (QuickTime) and .wmv. A container holds compressed video and audio streams, and almost all video in these containers uses lossy compression.

Program, web and archive files

Programs: .exe is a Windows executable program and .msi a Windows installer package; .bat is a batch file of commands; .dll is a library of code used by other programs; .apk installs an app on Android, .ipa on iOS and .dmg is a macOS disk image used to distribute software.

Web and code: .html or .htm is a web page, .css a style sheet and .js a JavaScript file; .py is Python source, .c is C source and .java is Java source, which compiles to .class files.

Archives: .zip, .rar, .7z, .tar and .gz bundle and compress files and folders into one file for easier sharing. An .iso file is an exact image of a CD or DVD.

Compression: lossless and lossy

Compression makes files smaller by storing the data more efficiently. Lossless compression lets the original be rebuilt exactly, bit for bit; it is essential for documents and programs and is used by ZIP, RAR, PNG, GIF and FLAC.

Lossy compression permanently throws away detail that people are unlikely to notice, giving much smaller files; it is used by JPEG, MP3, AAC and most video. Saving a JPEG again and again loses a little more each time, and converting it to a lossless format later cannot bring back what was lost.

Run-length encoding (RLE) is a simple lossless method that replaces a run of repeated symbols with a count and the symbol, so AAAABBB becomes 4A3B. It works well for images with large areas of one colour and badly for data with few repeats.

Solved examples

  1. Name the program normally used to open each file: budget.xlsx, notes.txt, slides.pptx, form.pdf.
    1. .xlsx is an Excel workbook.
    2. .txt is plain text, opened by Notepad or any text editor.
    3. .pptx is a PowerPoint presentation.
    4. .pdf opens in a PDF reader such as a web browser or Adobe Acrobat Reader.
    Answer: Excel; a text editor; PowerPoint; a PDF reader
  2. Classify each as lossy or lossless: a JPEG photo, a ZIP of office documents, an MP3 song, a PNG logo.
    1. JPEG and MP3 throw away detail to save space, so they are lossy.
    2. ZIP must restore documents exactly and PNG keeps every pixel, so both are lossless.
    Answer: Lossy: JPEG, MP3. Lossless: ZIP, PNG
  3. Ali zips a 48 MB folder and the ZIP file is 12 MB. Find the compression ratio and the percentage of space saved.
    1. Compression ratio = 48 ÷ 12 = 4, written 4:1.
    2. Space saved = (48 − 12) ÷ 48 × 100 = 75%.
    Answer: Ratio 4:1; 75% saved
  4. Compress WWWWWWBBBWWWW with run-length encoding, writing each run as count then symbol. How many characters are saved?
    1. The runs are 6 W, 3 B and 4 W.
    2. Encoded: 6W3B4W, which has 6 characters.
    3. The original has 13 characters, so 13 − 6 = 7 characters are saved.
    Answer: 6W3B4W; 7 characters saved
  5. Neha needs (i) a school logo with a transparent background for a website, (ii) a small looping animation for a notice board page, and (iii) an admission form that prints the same on every computer. Choose a format for each.
    1. A transparent, sharp-edged logo with no quality loss suits PNG.
    2. A short simple animation suits GIF.
    3. A document that must keep its exact layout everywhere suits PDF.
    Answer: PNG, GIF and PDF
  6. Ravi renames lecture.mp4 to lecture.mp3, hoping to get just the audio. What happens?
    1. Renaming changes only the label, not the data inside the file.
    2. The file still holds MP4 video data, so an MP3 player may fail to play it or play it incorrectly.
    3. To get an audio file he must use conversion software that extracts the sound and encodes it as MP3.
    Answer: Nothing is converted; he needs conversion software

Exam shortcuts

Common mistakes

Practice MCQs

  1. What does PDF stand for?
    A) Printable Document File
    B) Portable Data Format
    C) Portable Document Format
    D) Public Document Format
    Answer: C) Portable Document Format — PDF is Portable Document Format, developed by Adobe so that a document keeps the same layout on any device. The other expansions are invented.
  2. Which extension is used for a plain text file that holds no fonts, colours or images?
    A) .txt
    B) .rtf
    C) .docx
    D) .pdf
    Answer: A) .txt — A .txt file holds only characters. Rich Text Format (.rtf) keeps basic formatting, .docx is a formatted Word document, and .pdf stores a fixed page layout with fonts and images.
  3. What does CSV stand for in a file such as marks.csv?
    A) Computer system values
    B) Comma-separated values
    C) Column sorted values
    D) Coded spreadsheet view
    Answer: B) Comma-separated values — A CSV file is a plain-text table in which commas separate the values in each row. The other expansions are made up.
  4. Which file extension normally belongs to a Windows program that runs when double-clicked?
    A) .log
    B) .csv
    C) .png
    D) .exe
    Answer: D) .exe — An .exe file is a Windows executable program. A .log file is a text record of events, .csv is a text table and .png is an image; none of them runs as a program.
  5. What is the default file extension of a workbook saved in Microsoft Excel 2007 or a later version?
    A) .xls
    B) .xlsx
    C) .xlsm
    D) .csv
    Answer: B) .xlsx — Since Excel 2007 the default workbook format is .xlsx. The .xls format is the older Excel 97-2003 format, .xlsm is only for macro-enabled workbooks, and .csv is a plain-text table that Excel can open but does not use by default.
  6. Which image format is limited to 256 colours and supports simple animation?
    A) JPEG
    B) BMP
    C) GIF
    D) TIFF
    Answer: C) GIF — GIF stores up to 256 colours per frame and can hold several frames that play as an animation. JPEG, BMP and TIFF support millions of colours, and none of them is used for animation.
  7. Which file extension is used to install an app on an Android phone?
    A) .apk
    B) .exe
    C) .ipa
    D) .dmg
    Answer: A) .apk — Android apps are packaged as .apk files. An .exe runs on Windows, an .ipa is an iPhone or iPad app package, and a .dmg is a macOS disk image.
  8. Which of these image formats uses lossy compression?
    A) PNG
    B) GIF
    C) BMP
    D) JPEG
    Answer: D) JPEG — JPEG throws away fine detail to make photos smaller, so it is lossy. PNG and GIF compress without loss, and BMP is usually stored without any compression.
  9. Which pair of extensions are both compressed archive formats?
    A) .zip and .rar
    B) .zip and .mp4
    C) .rar and .pdf
    D) .7z and .png
    Answer: A) .zip and .rar — ZIP and RAR both bundle many files and folders into one compressed file. In each other pair one item is not an archive: .mp4 is a video, .pdf is a document and .png is an image.
  10. Which of these is a lossless compressed audio format?
    A) MP3
    B) AAC
    C) FLAC
    D) AMR
    Answer: C) FLAC — FLAC shrinks audio while allowing the exact original sound to be rebuilt. MP3, AAC and AMR are all lossy, discarding some sound information to get smaller files.
  11. Sana needs her company logo on a website with a transparent background and crisp edges, with no loss of quality. Which format should she use?
    A) JPEG
    B) BMP
    C) MP4
    D) PNG
    Answer: D) PNG — PNG is lossless and supports transparency, so the logo stays sharp over any background. JPEG has no transparency and blurs sharp edges, BMP has no practical transparency and is large, and MP4 is a video format.
  12. Imran compresses a 60 MB folder into a 15 MB ZIP file. What percentage of space has been saved?
    A) 25%
    B) 75%
    C) 45%
    D) 80%
    Answer: B) 75% — Space saved = (60 − 15) ÷ 60 × 100 = 75%. 25% is the size of the ZIP as a share of the original, not the saving; 45% treats the 45 MB saving as a percentage directly, and 80% does not follow from the figures.
  13. Using run-length encoding in which every run, even a run of one, is written as the count followed by the symbol, what is AAAAABBCCCCCCD compressed to?
    A) 5A2B6CD
    B) 5A2B5C1D
    C) 5A2B6C1D
    D) 4A2B6C1D
    Answer: C) 5A2B6C1D — The runs are five A, two B, six C and one D, giving 5A2B6C1D. Writing D without its count breaks the stated rule, and the other two miscount the runs of C or A.
  14. A ZIP tool shrinks text files to 30% of their original size. Ayesha zips 7 text files of 12 MB each. About how large is the ZIP file?
    A) 58.8 MB
    B) 84 MB
    C) 3.6 MB
    D) 25.2 MB
    Answer: D) 25.2 MB — The files total 7 × 12 = 84 MB, and 30% of 84 MB is 25.2 MB. 58.8 MB is 70% of the total, 84 MB is the uncompressed size, and 3.6 MB is the compressed size of only one file.
  15. Bilal edits a JPEG photo, saves it as JPEG several times and then converts it to PNG. Which statement is correct?
    A) The PNG prevents further loss but cannot restore detail already lost
    B) The PNG restores the photo to its original quality
    C) Repeated JPEG saves never reduce quality
    D) The PNG will always be smaller than the JPEG
    Answer: A) The PNG prevents further loss but cannot restore detail already lost — Each lossy JPEG save discards a little more detail, and that detail is gone for good; PNG is lossless, so it keeps the current image exactly but cannot bring back what was discarded. A PNG of a photo is normally larger than the JPEG, not smaller.

Questions

Can I see file extensions in Windows?

Yes. In File Explorer, turn on the option to show file name extensions. This also helps you spot disguised files such as photo.jpg.exe.

Is a .docx file really a ZIP file?

Yes. Office formats ending in x are collections of XML files packed with ZIP compression, which is why they are smaller than the older .doc format.

Should I use JPEG or PNG?

Use JPEG for photographs, where small losses are invisible and file size matters. Use PNG for logos, screenshots, diagrams and anything that needs sharp edges or transparency.

Why does zipping a JPEG or MP3 barely reduce its size?

These files are already compressed, so little repetition is left for ZIP to remove.