0% found this document useful (0 votes)
4 views

Ouput_Program

The document outlines a computer programming examination for students in grades VII-XII and higher education courses like MCA, BCA, and B.TECH. It includes various questions on Java programming concepts, operator precedence, and practical coding tasks. Additionally, it features programming assignments related to evil numbers, tech numbers, and emirp numbers.

Uploaded by

kapoor.aarav0226
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)
4 views

Ouput_Program

The document outlines a computer programming examination for students in grades VII-XII and higher education courses like MCA, BCA, and B.TECH. It includes various questions on Java programming concepts, operator precedence, and practical coding tasks. Additionally, it features programming assignments related to evil numbers, tech numbers, and emirp numbers.

Uploaded by

kapoor.aarav0226
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
You are on page 1/ 5

MAHADEVI EDUCATON ACADEMY

(GOVT.REGD.)

Computer VII-XII (all boards)

MCA, BCA, B.TECH and Others (Programming Only and Practical Based)

Output and Program

Full Marks: - 60

Time: - 1hrs 40 min

Question 1

The precedence of operators in Java follows BODMAS.


Question 2

The output of a++ will be 1, if int a = -1.


Question 3

The relational operators always result in terms of 'True' or 'False'.


Question 4

Given: int m=5; m*=5 then the value stored in m results in 55.
Question 5

The statement (a>b)&&(a>c) uses a logical operator.


Question 6

If int a=27,b=4,c=0; then c = a % b; results in 3.


Question 7

The statement p += 5 means p = p*5.


Question 8

In the precedence of logical operators; NOT is followed by AND.

Write Java expressions

Question 1

ab+cd33ab+cd

Question 2

p3+q4−12rp3+q4−21r

Question 3

−b+b2−4ac2a2a−b+b2−4ac

Question 4
Centre at-Baguiati, Jyangra, Teghoria, Manicktalla, Khanna

79802 96633
MAHADEVI EDUCATON ACADEMY

(GOVT.REGD.)

Computer VII-XII (all boards)

MCA, BCA, B.TECH and Others (Programming Only and Practical Based)

0.05−2y3(x−y)(x−y)0.05−2y3

Question 5

mn+(m+n)3mn+3(m+n)

Predict the output

Question 1

int c = (3<4)? 3*4 : 3+4;

Question 2

int a = 14, b = 4; boolean x = (a > b) ? true : false;

Question 3

int x = 90;
char c = (x<=90)? 'Z' : 'I';

Question 4

int a = 18; int b = 12;


boolean t = (a > 20 && b < 15)? true : false;

Question 5

c = (val + 550 < 1700)? 200: 400;


if: (a) val = 1000 (b) val = 1500

Answer the following questions

Question 1

What is an operator? What are the three main types of operators? Name them.

Question 2

How is Java expression different from statement?

Question 3

Explain the following with one example each.

(a) Arithmetic operator

(b) Relational operator

Centre at-Baguiati, Jyangra, Teghoria, Manicktalla, Khanna

79802 96633
MAHADEVI EDUCATON ACADEMY

(GOVT.REGD.)

Computer VII-XII (all boards)

MCA, BCA, B.TECH and Others (Programming Only and Practical Based)

(c) Logical operator

Question 4

Distinguish between:

(a) Unary & Binary arithmetic operator

Question 5

What will be the output of the following code?

int k=5,j=9;

k += k++ - ++j + k;

System.out.println ("k="+k);

System.out.println ("j="+j);

Question 6

If int y =10 then find int z = (++y*(y++ + 5));

Question 7

Give the output of the following expression:


a += a++ + ++a + --a + a--; when a = 7;

Question 8

What is the value of y after the execution?


y += ++y + y-- + --y; when int y=8

Question 9

Rewrite the following program segment using if-else statements instead of the ternary operator.

(a) String grade = (marks>=90)?"A": (marks>=80)? "B": "C";

(b) commission = (sale > 5000) ? sale*10/100 : 0;

(c) net = (salary > 10000) ? salary - (8.33/100)*salary : salary - (5/100)*salary

(e) c = (x >= 'A' && x <= 'Z') ? "Upper Case Letter" : "Lower Case Letter";

Question 10

Rewrite the following using ternary operator.


Centre at-Baguiati, Jyangra, Teghoria, Manicktalla, Khanna

79802 96633
MAHADEVI EDUCATON ACADEMY

(GOVT.REGD.)

Computer VII-XII (all boards)

MCA, BCA, B.TECH and Others (Programming Only and Practical Based)

(a)

if (x % 2 == 0)

System.out.println("Even");

else

System.out.println("Odd");

(c)

if(income < 10000)

tax = 0;

else

tax = 12;

(e)

if (p >= 4750)

k = p * 5 / 100;

else

k = p * 10 / 100;

Program 1

An Evil number is a positive whole number which has even number of 1's in its binary
equivalent. Example: Binary equivalent of 9 is 1001, which contains even number of 1's. A few
evil numbers are 3, 5, 6, 9…. Design a program to accept a positive whole number and find the
binary equivalent of the number and count the number of 1's in it and display whether it is a
Evil number or not with an appropriate message. Output the result in format given below:

Example 1
Input: 15
Binary Equivalent: 1111
No. of 1's: 4
Output: Evil Number

Example 2
Input: 26

Centre at-Baguiati, Jyangra, Teghoria, Manicktalla, Khanna

79802 96633
MAHADEVI EDUCATON ACADEMY

(GOVT.REGD.)

Computer VII-XII (all boards)

MCA, BCA, B.TECH and Others (Programming Only and Practical Based)

Binary Equivalent: 11010


No. of 1's: 3

Program 2

A tech number has even number of digits. If the number is split in two equal halves, then the
square of sum of these halves is equal to the number itself. Write a program to generate and
print all four digits tech numbers.

Example:

Consider the number 3025

Square of sum of the halves of 3025 = (30 + 25)2


= (55)2
= 3025 is a tech number.

Program 3

Write a program to input a number and find whether the number is an emirp number or not. A number is said to
be emirp if the original number and the reversed number both are prime numbers.

For example, 17 is an emirp number as 17 and its reverse 71 are both prime numbers.

Centre at-Baguiati, Jyangra, Teghoria, Manicktalla, Khanna

79802 96633

You might also like