0% found this document useful (0 votes)
18 views2 pages

Java Object-Oriented Programming Exam Questions

The document contains previous year exam questions for the Object Oriented Programming Using Java (BCS306A) course, covering various topics such as control statements, operators, arrays, object-oriented programming features, and programming examples. It includes questions from multiple exam sessions, focusing on practical programming tasks and theoretical concepts. The questions are designed to assess students' understanding and application of Java programming principles.

Uploaded by

noxofi6124
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Java Object-Oriented Programming Exam Questions

The document contains previous year exam questions for the Object Oriented Programming Using Java (BCS306A) course, covering various topics such as control statements, operators, arrays, object-oriented programming features, and programming examples. It includes questions from multiple exam sessions, focusing on practical programming tasks and theoretical concepts. The questions are designed to assess students' understanding and application of Java programming principles.

Uploaded by

noxofi6124
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Object Oriented Programming Using Java (BCS306A) Questions from

Previous year Question papers

module 1
June/July 2025

1. List and explain control statements in java with programming examples. (10)
2. List and explain operators in java. (10)
3. How are arrays declared and initialized in Java? Explain with suitable example.
(10)
4. Develop a java program to add two metrices of suitable order N. (10)

Dec 2024 /Jan 2025

1. List and explain any three features of object-oriented programming. (6)


2. What do you mean by type conversion and type casting? give examples. (8)
3. How to declare and initialize 1D and 2D arrays in Java. Give examples. (6)
4. List the short circuit operators and show the concept of using few examples. (4)
5. With a Java program illustrate the use of ternary operator to find the greatest of
three numbers. (6)
6. Develop a Java program to demonstrate the working of four each version of for
loop. Initialize the 2D array with values and print them using for each. (10)

June/July 2024

1. define two paradigms of programming. (5)


2. Explain the various bitwise and short-circuit operators in Java. (8)
3. Write a Java program with method to check whether a given number is prime or
not. (7)
4. Explain various scopes of variables in Java. (5)
5. Explain the arithmetic compound assignment and ternary operators in Java. (8)
6. Write a Java program to perform linear search on an array elements accepted
from keyboard and key element also accepted from keyboard. (7)
Dec 2023/Jan 2024

1. Discuss the different data types supported by Java along with default values and
literals. (8)
2. Develop a Java program to convert Celsius temperature to Fahrenheit. (6)
3. Justify the statement “compile once and run anywhere” in Java. (6)
4. List the various operators supported by Java. Illustrate the working of >> and >>>
operators with an example. (8)
5. Develop a Java program to add two matrices using command line arguments.
(10)
6. Explain the Syntax of declaration of 2D arrays in Java. (2)

Model Paper

1. Explain different lexical issues in JAVA. (7)


2. Define Array. Write a Java program to implement the addition of two matrixes. (7)
3. Explain the following operations with examples. (i)<< (ii)>> (iii)>>> (6)
4. Explain object-oriented principles. (7)
5. Write a Java program to sort the elements using a for loop. (7)
6. Explain different types of if statements in JAVA. (6)

Common questions

Powered by AI

Object-oriented programming (OOP) is characterized by encapsulation, inheritance, and polymorphism. Encapsulation involves bundling data with the methods that operate on this data. Inheritance allows creating new classes that are based on existing ones, promoting code reuse. Polymorphism enables the calling of methods in derived classes through their base class references, allowing for method overriding. These features distinguish OOP by promoting modular, maintainable, and reusable code .

Type conversion in Java refers to converting one data type to another, which could be implicit or explicit. Implicit conversion, or 'widening', occurs when a smaller data type is automatically converted to a larger type, while explicit conversion or 'casting' requires manual intervention using a cast operator, especially when converting a larger type to a smaller one ('narrowing'). For example, assigning an int to a double is implicit, while converting a double to an int involves explicit casting using (int). Understanding these conversions is crucial to manage type compatibility and precision in Java programs .

Lexical issues in Java refer to problems related to the syntax and the tokens utilized within the code. Common lexical issues include incorrect usage of keywords, invalid identifiers (e.g., starting identifiers with numbers), and improper handling of literals and comments. These issues can lead to compilation errors since the compiler fails to recognize malformed tokens or syntax errors within the source code. Ensuring that code adheres to Java's lexical syntax is crucial for successful compilation and execution .

Java achieves platform independence through its use of the Java Virtual Machine (JVM). When Java source code is compiled, it is transformed into bytecode by the Java compiler. This bytecode is not machine-specific; instead, it can be executed by any JVM, which is available for most platforms. This architecture allows Java programs to be written on one platform and executed on any other platform with a compatible JVM, thus fulfilling the 'write once, run anywhere' capability .

Bitwise operators, like '&', '|', '^', are used to perform operations on binary representations of integers. They are utilized for low-level programming tasks, such as bit manipulation. In contrast, short-circuit logical operators, '&&' and '||', evaluate conditional expressions. Short-circuits can bypass unnecessary evaluations since expressions are evaluated only as needed to determine a condition's truth value, which often results in performance optimizations in complex conditional statements .

In Java, the '<<' operator performs a bitwise left shift, moving bits to the left and inserting zeros on the right, equivalent to multiplying by powers of two. The '>>' operator conducts an arithmetic right shift, moving bits to the right while preserving the sign bit on the left, effectively dividing by powers of two while keeping sign. The '>>>' is a logical right shift, which also shifts bits right but inserts zeros regardless of sign, which is useful in unsigned context operations. An example is shifting an integer to manipulate data in tasks like checksum calculations .

Control statements in Java guide the flow of execution based on certain conditions, allowing for more dynamic and responsive programs. The primary control statements include decision-making statements like 'if', 'else-if', and 'switch', which allow executing code blocks based on conditional expressions. For iteration, Java offers loops such as 'for', 'while', and 'do-while', enabling repeated execution of code blocks. Additionally, 'break' and 'continue' statements provide finer control within loops. The use of these control structures can be illustrated through examples like using a 'for' loop to iterate over array elements or an 'if-else' statement to check and execute code based on specific conditions .

The ternary operator is a shorthand for the 'if-else' statement in Java, used for decision-making with the syntax `expression ? value_if_true : value_if_false`. For finding the greatest of three numbers, the operator can be nested as: `int greatest = (a > b) ? (a > c ? a : c) : (b > c ? b : c);`. This concise form compares 'a' and 'b', then the result against 'c' to determine the maximum number with fewer lines of code than traditional nested 'if-else' structures .

Java variables have four types of scopes: local, class/static, instance, and method. Local variables are declared within a method and are accessible only within that method. Class/static variables are declared with the static keyword inside a class, shared among all instances, and accessible through the class name. Instance variables are fields within a class accessed through class instances. Method parameters are also local, with scope limited to the method. These scoping rules determine the visibility and lifetime of variables, crucial for code organization and avoiding conflicts .

Arrays in Java are used to store multiple values of the same type in a contiguous memory location, allowing easy management and access via indices. A 1D array is declared as `type[] arrayName = new type[size];`. For a 2D array, it's declared as `type[][] arrayName = new type[rows][columns];`. For example, `int[] numbers = {1, 2, 3};` initializes a 1D array, while `int[][] matrix = {{1, 2}, {3, 4}};` initializes a 2D array. Arrays are significant in simplifying data handling, enabling batch processing with loops .

You might also like