What is the main function of a compiler in programming?
A Execute code
B Interpret code
C Translate code
D Debug code
A compiler translates high-level source code into machine code or an intermediate code that the computer’s processor can execute directly. It performs syntax checking and optimization, making the program ready for execution.
In Java, which of the following is used to create a graphical user interface (GUI)?
A java.gui
B java.io
C java.awt
D javax.swing
javax.swing is the package used in Java to create graphical user interfaces. It provides components like buttons, panels, and text fields, which are essential for building GUI-based applications.
Which of these is a key feature of an interpreted language?
A Fast execution
B Immediate feedback
C Compilation required
D No debugging
Interpreted languages, like Python, execute code line by line, providing immediate feedback. This is useful for debugging and development, as errors are reported instantly, unlike compiled languages where you must recompile after each change.
What is the purpose of a web browser in web development?
A Interpret HTML, CSS, and JavaScript
B Display code
C Execute backend code
D Compile source code
A web browser interprets and renders HTML, CSS, and JavaScript to display web pages to the user. It acts as a client-side tool, allowing users to interact with websites and web applications.
In Python, which module is used to work with GUI applications?
A pyGUI
B os
C Tkinter
D socket
Tkinter is the standard Python library for creating graphical user interfaces. It provides widgets such as buttons, labels, and text fields, making it easy to develop desktop applications with graphical interfaces.
Which of the following is the first step in the process of compiling a C program?
A Preprocessing
B Linking
C Assembling
D Execution
The first step in compiling a C program is preprocessing, which handles directives like #include and #define. It processes macro definitions, file inclusions, and conditional compilations before moving to the next stages.
In Java, which layout manager is used to arrange components in a grid?
A FlowLayout
B BorderLayout
C GridLayout
D BoxLayout
GridLayout in Java is used to arrange components in a grid of rows and columns. Each cell in the grid holds one component, making it useful for applications that require structured placement of elements.
Which of these languages is an interpreted language?
A C
B Java
C C++
D Python
Python is an interpreted language, meaning its code is executed line by line by an interpreter, rather than being compiled into machine code beforehand. This allows for easier debugging and rapid development.
What does the javac command do in Java?
A Run the program
B Compile the code
C Interpret the code
D Debug the code
In Java, the javac command is used to compile source code into bytecode. This bytecode can then be executed on the Java Virtual Machine (JVM), which allows Java programs to run on any platform.
In web development, which language is primarily used for structuring content on the web?
A CSS
B JavaScript
C HTML
D PHP
HTML (HyperText Markup Language) is the standard language used for structuring content on the web. It defines the structure of web pages using tags like <h1>, <p>, and <div> to organize and display content.
In Python, which function is used to run a Tkinter application?
A root.mainloop()
B Tkinter.run()
C Tkinter.start()
D Tkinter.execute()
In Python’s Tkinter module, root.mainloop() is used to start the Tkinter event loop. It keeps the window open and waits for user interactions like button clicks or key presses, ensuring the GUI remains active.
Which of the following is used to style a webpage in web development?
A HTML
B JavaScript
C PHP
D CSS
CSS (Cascading Style Sheets) is used to style and layout web pages. It controls the visual appearance of elements defined in HTML, such as colors, fonts, and spacing, allowing web developers to design attractive websites.
What is the key difference between compiled and interpreted languages?
A Compilation speed
B Memory usage
C Execution speed
D Error handling
Compiled languages, such as C, are converted directly into machine code, which allows faster execution. Interpreted languages, like Python, are executed line by line, making them slower than compiled languages in most cases.
Which Java class is used to handle user input from the console?
A Scanner
B FileReader
C BufferedReader
D Console
In Java, the Scanner class is used to read user input from the console. It can handle various input types such as strings, integers, and doubles, providing a simple way to collect data from the user.
What is the primary use of the BufferReader class in Java?
A Reading characters from a file
B Reading bytes from a file
C Writing data to a file
D Reading integers from a file
In Java, the BufferedReader class is used to read characters from a file or input stream. It buffers the input, allowing for efficient reading of large amounts of data, particularly when dealing with text files.