Preview

Java Programming Questions

Good Essays
Open Document
Open Document
1971 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java Programming Questions
BSIT 4P
B.Sc.(IT) 4th Semester
Practical Question Paper Set
(Give any one set to each student randomly)

Set- 1

Write a program to print “ Welcome to Java Programming” on the screen

public class welcome
{
public static void main (String args[])
{
System.out.println("Welcome to Java programming");
}
}

Using a case statement, write a shell program to read a command (eg., who, cal, ls, ps) from the user and execute it.

echo "let me know what you want to do" while : a=0; do echo "1 : who command 2: cal command 3: ls command 4 : ps command 5: exit " echo "enter your choice : " read a case $a in
1) echo `who`;;
2) echo `cal`;;
3) echo `ls`;;
4) echo `ps`;;
5) exit ;;
*) echo "this option is not available" ;; esac done

Set- 2

Using awk, sum the file sizes in your working directory and print the results.

ls -l | awk '/^-/ {total+=$5} END{print "Total of all file sizes "total}'

Write a program to check whether the given two numbers are equal. If not then find the greater of the given two numbers.

import java.io.*; import java.math.*; class Greatest
{
public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n1,n2; System.out.println("Enter the values for n1,n2"); n1=Integer.parseInt(br.readLine()); n2=Integer.parseInt(br.readLine());

if( n1 == n2) { System.out.println("Both the numbers are equal"); } else if( n1 > n2 ) { System.out.println("First number is greater than second"); } else { System.out.println("Second number is greater than first"); } }
}

Set- 3

Using switch and case statements write a program to add, subtract, multiply and divide the two numbers

import java.io.*; public class Cal
{
public static void main(String args[])throws Exception
{
int a,b,c=0;
BufferedReader

You May Also Find These Documents Helpful

  • Satisfactory Essays

    a1 script win213

    • 380 Words
    • 2 Pages

    If the user does not enter a numeric value the program should prompt for a numeric value…

    • 380 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    = z) return true; else return false; } Problem 5 a. Output: 720 b. Output: 0 c. Output: 71 d. Output: 362880 Problem 6 a. Output: “Take Programming I.” b. Output:…

    • 188 Words
    • 1 Page
    Satisfactory Essays
  • Better Essays

    Nt1310 Unit 4

    • 3614 Words
    • 15 Pages

    13. If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday? What would be the output?…

    • 3614 Words
    • 15 Pages
    Better Essays
  • Good Essays

    Nt1310 Unit 3 Quiz

    • 6337 Words
    • 26 Pages

    /*question number 1*/ Code: int z,x=5,y=-10,a=4,b=2; z = x++ - --y * b / a; What number will z in the sample code above contain? Choice 1 5 Choice 2 6 Choice 3…

    • 6337 Words
    • 26 Pages
    Good Essays
  • Satisfactory Essays

    Homework Unit 3

    • 354 Words
    • 2 Pages

    4. AND operator- combines more than one condition in a program. Makes a compunf Boolean operation.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Unit 2 NT1430

    • 377 Words
    • 2 Pages

    8. What is the result of giving the which utility the name of a command that resides in a…

    • 377 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    2.Write a program to (a) display a “?” (b) read two decimal digits whose sum less than 10 (c) display them and their sum on the next line. Page: 80…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    It210 Appendix F

    • 372 Words
    • 3 Pages

    1. The program will present a series of user screens that prompts the user for specified input.…

    • 372 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    Java Chapter 2 Quiz

    • 2047 Words
    • 9 Pages

    4. The ____ is normally considered the standard output and standard input devices, and usually refer to…

    • 2047 Words
    • 9 Pages
    Powerful Essays
  • Satisfactory Essays

    IT 210 appendix d

    • 264 Words
    • 2 Pages

    H. Running a program using various sets of inputs to determine if the program is running properly…

    • 264 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Week 5 Assignments New

    • 754 Words
    • 6 Pages

    3.) Design an if-then-else statement that assigns 0 to variable b if variable a is less than 10, otherwise it should assign 99 to variable b. (Alternative if statement)…

    • 754 Words
    • 6 Pages
    Satisfactory Essays
  • Good Essays

    COS wa 10

    • 297 Words
    • 2 Pages

    Create a set/list of enumerated constants called week that contains the days of the week. Have a variable called today that is of type week. Assign a value to today. If the day is Monday through Friday, print "Go to work!" If the day is Saturday or Sunday, print "You can rest today!"…

    • 297 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Assignment 2

    • 338 Words
    • 2 Pages

    3.) Input, and display, the total of the numeric input after each input is entered. Average the numeric input, indicate lowest numeric input value and the highest numeric input value for the previous numeric inputs, before the next numeric input is asked for. (Example given in class)…

    • 338 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Java

    • 5076 Words
    • 21 Pages

    Explanation: E) We convert each of these capacities to bytes (rounding off) to compare them. The value in A remains the same, 1 1/2 trillion bytes. The value in B is 100 billion bytes. The value in C is 3 1/2 billion bytes. The value in D is 10 trillion bytes. The answer in E is 12 trillion bytes.…

    • 5076 Words
    • 21 Pages
    Good Essays
  • Good Essays

    Programming Homework

    • 366 Words
    • 2 Pages

    Write a program that would calculate and display the results for the multiplication table for values ranging from 1 to 100.…

    • 366 Words
    • 2 Pages
    Good Essays