SRM INSTITUTE OF SCIENCE AND TECHNOLOGY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF COMPUTATIONAL INTELLIGENCE 21CSC203P ADVANCED PROGRAMMING Name Ananya Adini Reg. No. RA2511003011305 Branch B.Tech Computer Science and Engineering Section B2 Session Session 1: Introduction to Programming Languages SLO SLO 2: Language Classification SLO 2: Language Classification Answer: Java is both compiled and interpreted. The Java source code (.java) is first compiled by the Java compiler (javac) into platform-independent bytecode (.class). The Java Virtual Machine (JVM) then executes this bytecode by interpretation and/or Just-In-Time (JIT) compilation into native machine code. Therefore, Java combines compilation and interpretation. Classify Java as compiled/interpreted and explain why. Example Java program: public class Hello { public static void main(String[] args) { System.out.println("Hello World"); } } Conversion to bytecode: Save the source file as Hello.java. Compile it using javac Hello.java. The compiler checks the source code and generates Hello.class, which contains Java bytecode. The JVM loads and executes this bytecode, interpreting it and/or using JIT compilation to produce native machine instructions.
Write a simple Java program and explain how it is converted to bytecode. Feature Low-Level Language High-Level Language Meaning Closer to hardware and machine instructions. Closer to human language and easier to understand. Examples Machine language, Assembly language. Java, C, C++, Python. Portability Generally machine-dependent. Generally more portable across systems. Ease of programming More difficult and hardware-oriented. Easier to write, read, and maintain. Abstraction Provides little abstraction from hardware. Provides a higher level of abstraction. Conclusion: Low-level languages provide greater control over hardware, whereas high-level languages provide easier programming through greater abstraction.
