0% found this document useful (0 votes)
29 views4 pages

Batch 28 Task-4

The document contains 12 multiple choice questions related to Java programming concepts like data types, operators, type casting etc. It also contains 2 programming questions to write Java code to perform string to double conversion, find ASCII value of a character and calculate profit/loss using given formulas.

Uploaded by

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

Batch 28 Task-4

The document contains 12 multiple choice questions related to Java programming concepts like data types, operators, type casting etc. It also contains 2 programming questions to write Java code to perform string to double conversion, find ASCII value of a character and calculate profit/loss using given formulas.

Uploaded by

pavan sai narra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Que-1)

____________________-
What is the output of the following Java Code?

int a=9;
float b = a/2;
System.out.println(b);

a 4.0
b 4.5
c 5.0
d None of the above
_____________________________________________________________________
Que-2
____________________
What is the output of the below Java code snippet?

char ch = 'A';//ASCII 65
int a = ch + 1;
ch = (char)a;
System.out.println(ch);

a 66
b A
c B
d 65
_________________________________________________________________________
QUE-3)
___________________
What is the output of the below Java code snippet?

float a = 8.2/2;
System.out.println(a);

a.
4.1
b.
8.1
c.
4
d.
Compiler error
__________________________________________________________________________
Que-4)
__________________
What is the output of the Java code snippet?

int a = 260;
byte b= (byte)a;
System.out.println(b);

a.
0
b.
4
c.
255
d.
260
__________________________________________________________________________
Que-5)
__________________
What is the output of the Java code snippet?

short a = (short)65540;
System.out.println(a);

a.
0
b.
4
c.
65536
d.
65540
__________________________________________________________________________
Que-6)
__________________
public class MyFirstJavaProgram {
public static void main(String []args) {
int a = 300;
long b = a;
System.out.println(b);
}
}
__________________________________________________________________________
Que-7)
________________
public class WideningExample {
public static void main(String args[]){
char ch = 'C';
int i = ch;
System.out.println(i);
}
}
__________________________________________________________________________
Que-8)
________________
public class Sample {
public static void main(String[] args)
{
System.out.print("Y"+"O");
System.out.print('L');
System.out.print('O');
}
}
__________________________________________________________________________
Que-9)
________________
public class Sample2 {
public static void main(String[] args)
{
System.out.print("Y"+"O");
System.out.print('L' + 'O');
}
}
_________________________________________________________________________
Que-10)
________________
class Sample3{
public static void main(String[] args)
{
int i = 100;
long l = i;
float f = l;
System.out.println("Int value " + i);
System.out.println("Long value " + l);
System.out.println("Float value " + f);
}
}
________________________________________________________________________
Que-11)
_______________
public class Sample4{
public static void main(String[] argv)
{
char ch = 'c';
int num = 88;
ch = num;
}
}
________________________________________________________________________
Que-12)
_______________
class Sample5{
public static void main(String args[])
{
byte b = 42;
char c = 'a';
short s = 1024;
int i = 50000;
float f = 5.67f;
double d = .1234;
double result = (f * b) + (i / c) - (d * s);
System.out.println("result = " + result);
}
}
________________________________________________________________________
Programming Questions
________________________________________________________________________
QUE-1)
-----------
Write a java program to covert string to double using parseDouble() and multiply
two Floating -point Numbers and display the result by taking input from the command
line argument?
-----------------------------------------------------------------------
Que-2)
-----------
Write a java program to find the ASCII value of a character
For Example
Output sholud be in below formart
The ASCII value of a is :97
----------------------------------------------------------------------
Que-3)
-----------
Write a java program to find the profit and loss by following the formula
Profit and loss Formulas �
Profit = SP � CP
Loss = CP � SP
Profit percentage = (Profit /Cost Price) x 100
Loss percentage = (Loss / Cost price) x 100

You might also like