PROGRAMMING FUNDAMENTALS

Similar documents
Computational Expression

Summer Holiday Home Work Informatics Practices Class 12 th

Introduction to Programming Using Java (98-388)

Lec 3. Compilers, Debugging, Hello World, and Variables

INDEX. A SIMPLE JAVA PROGRAM Class Declaration The Main Line. The Line Contains Three Keywords The Output Line

Primitive Types. Four integer types: Two floating-point types: One character type: One boolean type: byte short int (most common) long

Programming in C++ 6. Floating point data types

Expressions & Flow Control

Getting started with Java

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Program Fundamentals

Full file at

3. Java - Language Constructs I

Computer Components. Software{ User Programs. Operating System. Hardware

Following is the general form of a typical decision making structure found in most of the programming languages:

School of Computer Science CPS109 Course Notes 5 Alexander Ferworn Updated Fall 15

Java Bytecode (binary file)

B.V. Patel Institute of BMC & IT, UTU 2014

Language Reference Manual

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it.

Introduction to Java

Tools : The Java Compiler. The Java Interpreter. The Java Debugger

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Instructor: SIR MUHAMMAD NAVEED Created by: ARSLAN AHMED SHAAD ( ) MUHAMMAD BILAL ( ) ISIT:

Java Programming. Atul Prakash

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

1 Introduction Java, the beginning Java Virtual Machine A First Program BlueJ Raspberry Pi...

JAVA Programming Fundamentals

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2

Getting started with Java

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

CS313D: ADVANCED PROGRAMMING LANGUAGE

Chapter 5 Control Statements: Part 2 Section 5.2 Essentials of Counter-Controlled Repetition

Java Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2

CS313D: ADVANCED PROGRAMMING LANGUAGE

Fall 2017 CISC124 9/16/2017

Creating a C++ Program

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

CSC Java Programming, Fall Java Data Types and Control Constructs

CS 251 Intermediate Programming Java Basics

Section 2.2 Your First Program in Java: Printing a Line of Text

Java Fall 2018 Margaret Reid-Miller

( &% class MyClass { }

6.096 Introduction to C++ January (IAP) 2009

CSC 1214: Object-Oriented Programming

Programming Basics. Digital Urban Visualization. People as Flows. ia

Computer Programming, I. Laboratory Manual. Final Exam Solution

Computer Components. Software{ User Programs. Operating System. Hardware

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

Java Programming Basics. COMP 401, Spring 2017 Lecture 2

COMP 202 Java in one week

CIS 110: Introduction to Computer Programming

Basics of Java Programming

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

Lecture Set 4: More About Methods and More About Operators

CS 112 Introduction to Programming

Admin. CS 112 Introduction to Programming. Recap: Java Static Methods. Recap: Decomposition Example. Recap: Static Method Example

Programming with Java

Lecture Set 2: Starting Java

ARG! Language Reference Manual

The Java language has a wide variety of modifiers, including the following:

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Le L c e t c ur u e e 3 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Control Statements

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

An overview of Java, Data types and variables

Lecture Set 2: Starting Java

Java Language Basics: Introduction To Java, Basic Features, Java Virtual Machine Concepts, Primitive Data Type And Variables, Java Operators,

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

CSE 201 JAVA PROGRAMMING I. Copyright 2016 by Smart Coding School

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Exercise: Using Numbers

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Lexical Considerations

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.

Pace University. Fundamental Concepts of CS121 1

VARIABLES AND TYPES CITS1001

CS242 COMPUTER PROGRAMMING

Basic Java Syntax. COMP 401, Fall 2015 Lecture 2 1/13/2014

Chapter 2: Using Data

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

CS 112 Introduction to Programming

Language Reference Manual

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Computer Science is...

Primitive Data, Variables, and Expressions; Simple Conditional Execution

Java Notes. 10th ICSE. Saravanan Ganesh

Java Basic Programming Constructs

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

Lexical Considerations

Selected Questions from by Nageshwara Rao

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003

BM214E Object Oriented Programming Lecture 4

CS 231 Data Structures and Algorithms, Fall 2016

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

Chapter 3: Operators, Expressions and Type Conversion

Transcription:

PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write a comment in a program? What are the two ways of writing comment in a java Program? Q5. What is a syntax error in context of a program? Give an example.

Q6. What is RAD programming? Why is program development in java using Netbeans IDE is RAD? Q7. What is IDE? Name two IDE for Programming in java. Q8. Name any two type of Tokens available in Java. 9. What are primitive data types? Name the various primitive data type available in Java.

Q10. What are Reference data types? Q11. What is type casting? Q12. Name and explain the usage of any two data types used in Java to store numbers with decimals. Q13. What are Keywords? Give two examples of keywords available in Java. Q14. Name and explain the usage of any one relational and one logical operator in Java. Q15. What is the difference between = and == operator in java?

Q16. Name the two type of selection statement available in Java. Q17. Write the purpose of Switch Statement with the help of an example. Which Java Statement can be used in place of switch statement? In the switch statement, what happens if every case fails and there is no default option? Q18. What is the purpose of break statement in java? Q19. What is the purpose of continue statement in java? Q20 Find the output of the following code snippet written in java public static void main(string [ ]args) long a=78345,s1=0,s2=0,r; while(a>0) r=a%10; if (r%4==0) s1+= r; else s2+=r; a/=10; System.out.println("S1 ="+ s1); System.out.println("S2 ="+ s2);

Q21. Correct the errors in the following program segment written in JAVA. You are just required to write the corrected code, underlying the corrections made. public Static Void Main (String [] args) Integer Nos = 100; while (Nos => 45) If (Nos % 5 = 0); Nos+=10; otherwise Nos + = 20;

Answers Ans 1. C++ and Java Ans 2 Java program can be easily moved from one computer system to another, anywhere anytime. Changes and upgrade in operating system, processors and system resources will not force any change in the Java program. Hence it is called a platform independent language. Ans 3. The source program is first converted into a byte code using a java compiler. This byte code is machine independent i.e. same for all the machines. Later the byte code is executed on the machine using an interpreter. Ans 4. Comments are added to a program for the following purposes:- 1. Make the more readable and understandable 2. For future references we can add comments in a Java program in the following ways: i) Adding // before the line which is to be commented. This can be used only for single line comments. ii) using a pair of /* and */ for multi-line comments. Ans 5. Error in the way of writing a statement in a program, results in a syntax error. For e.g. for ( i=0, i<=100. i++), will result in a syntax because the program has written comma instead of a semi comma in the for loop. Ans 6. RAD stands for Rapid Application Development. A programming style which aims at building programs fastly through the use of tools and wizards is called RAD. Program development using Netbeans IDE is RAD as it provides GUI Provides online help and suggestions during typing of the program (using ctrl+ Spacebar key) Error alerts while typing of the program. Ans 7. A programming environment, where all the tools required for programming are available under one roof is called IDE. Two IDE for Java are Netbeans and BlueJ Ans 8. Keyword, Identifier, Literal, Punctuators ad Operators. Ans 9. Data types that are directly available with java are called primitive data type. Various primitive data types available in java are byte, short, int, long, float, double, char and boolean. Ans 10. Data types created by the programmer using the primitive data type are called reference data type e.g. Classes, interfaces etc. Ans11. Converting a value form one type to another is called type casting. For e.g. int a = 5. here a is a integer, which can be cased to float as follows float b = (float) a;

Ans12. Two data types available in java for storing numbers with decimals are 1. float: for single precision floating point values for e.g. float num = 10.0F 2. double: for double precision floating point value. This is the default data type for decimal numbers. for e.g. double num = 10.0 Ans13. Keywords are words that have a specific predefined meaning in Java. They cannot be used as variable names. Eg. void, private, if, while etc. Ans 14. One relational operator in java is ==. This operator results in true if both its operands are equal otherwise false. One logical operator in java is &&. This operator is used to combine two logical values. The result of the && will be true if and only if both its operands are true otherwise false. Ans15. Represent an assignment operator. It sets the value of the variable on its left side with the result of expression on its right side. == represent a conditional equal to operator. It checks for the equality of both its operands. If both the operands are equal, condition evaluates to true otherwise to false. Ans 16. Two selection statement available in java are if and Switch Ans 17. A Switch statement is used execute a statement from a group of statement based on the result of a expression. The expression must result in either of byte, short, integer or character. An if statement can be used in place of switch statement. In a switch statement if none of the statement satisfies and even there is no default case then nothing would happen. This would not result in any sort of error. Ans 18. Break is used to terminate the current switch statement or the loop. Ans 19. Continue statement skips the remaining part of the current loop and begins the next iteration of the loop. Ans 20. Output: s1= 12 s2= 15 Ans 21: Corrected Code public static void main (String [] args) int Nos = 100; while (Nos >= 45) if (Nos % 5 == 0)_ Nos+=10; else Nos + = 20;