Operators Questions

Similar documents
JAVA OPERATORS GENERAL

Prof. Navrati Saxena TA: Rochak Sachan

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

bitwise inclusive OR Logical logical AND && logical OR Ternary ternary? : Assignment assignment = += -= *= /= %= &= ^= = <<= >>= >>>=

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

1.Which four options describe the correct default values for array elements of the types indicated?

Selenium Class 9 - Java Operators

Chapter 3: Operators, Expressions and Type Conversion

1. Short circuit AND (&&) = if first condition is false then the second is never evaluated

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Operators. Java operators are classified into three categories:

Operators in java Operator operands.

Java Programming Language. 0 A history

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

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION

CSC 1214: Object-Oriented Programming

AP COMPUTER SCIENCE A

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

Questions and Answers.

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

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

Java Basic Programming Constructs

Lecture Set 4: More About Methods and More About Operators

Operators and Expressions

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

3 Operators and Assignments

Expressions and Precedence. Last updated 12/10/18

Java Programming for Selenium

Unit-2 (Operators) ANAND KR.SRIVASTAVA

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

The Arithmetic Operators

BSc (Hons) Computer Science with Network Security/ BSc (Hons) Software Engineering/ BSc (Hons) Web Technologies. Examinations for 2016 Semester 1

Object Oriented Programming Lecture (2.1) Supervisor Ebtsam AbdelHakam Department of Computer Science Najran University

Selections. EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG

Operators in C. Staff Incharge: S.Sasirekha

Operators & Expressions

Object-Oriented Programming

Chapter 3. Selections

Object-Oriented Programming. Topic 2: Fundamental Programming Structures in Java

13 th Windsor Regional Secondary School Computer Programming Competition

CS180. Exam 1 Review

d. If a is false and b is false then the output is "ELSE" Answer?

Term 1 Unit 1 Week 1 Worksheet: Output Solution

6 COMPUTER PROGRAMMING

CT 229 Java Syntax Continued

Sir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

Tutorial 06. Conditional statement: if then, if else, switch

Java Simple Data Types

Lecture Set 4: More About Methods and More About Operators

Department of Computer Science

Operators. 3 Two-Minute Drill CERTIFICATION OBJECTIVES Q&A. Using Operators. Self Test

Lara Technologies Special-Six Test

Programming Constructs Overview. Method Call System.out.print( hello ); Method Parameters

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

Motivating Examples (1.1) Selections. Motivating Examples (1.2) Learning Outcomes. EECS1022: Programming for Mobile Computing Winter 2018

Flow Control. Key Notion. Statement Categories. 28-Oct-10

CT 229. Java Syntax 26/09/2006 CT229

Getting started with Java

Operators. 3 Two-Minute Drill CERTIFICATION OBJECTIVES Q&A. Using Operators. Self Test

SOFTWARE DEVELOPMENT 1. Operators 2018W A. Ferscha (Institute of Pervasive Computing, JKU Linz)

Flow Control. Boaz Kantor Introduction to Computer Science, Fall semester IDC Herzliya

H212 Introduction to Software Systems Honors

CONDITIONAL EXECUTION

Day 2 : Intermediate Concepts 1 Examples

Unit 3. Operators. School of Science and Technology INTRODUCTION

Informatics Ingeniería en Electrónica y Automática Industrial

Object Oriented Software Design

Building Java Programs

Introduction to the Java Basics: Control Flow Statements

Data Types. 1 You cannot change the type of the variable after declaration. Zheng-Liang Lu Java Programming 52 / 87

Loops and Expression Types

(c) ((!(a && b)) == (!a!b)) TRUE / FALSE. (f) ((!(a b)) == (!a &&!b)) TRUE / FALSE. (g) (!(!a) && (c-d > 0) && (b!b))

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

CS 117 Fall Compound boolean expressions. Control Statements, Part 2. Using boolean operators. Boolean operators

Building Java Programs

CS 152 Computer Programming Fundamentals The if-else Statement

Key Java Simple Data Types

Introduction to Computer Science, Shimon Schocken, IDC Herzliya. Lectures Control Structures

Zheng-Liang Lu Java Programming 45 / 79

JAVA Programming Fundamentals

Chapter 3 Selection Statements

Lecture 3 Operators MIT AITI

Building Java Programs

Program Fundamentals

COMP6700/2140 Operators, Expressions, Statements

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Some Sample AP Computer Science A Questions - Solutions

More types, Methods, Conditionals. ARCS Lab.

Java Simple Data Types

Tutorial # 4. Q1. Evaluate the logical (Boolean) expression in the following exercise

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

CS111: PROGRAMMING LANGUAGE II

A flow chart is a graphical or symbolic representation of a process.

Activity 6: Loops. Content Learning Objectives. Process Skill Goals

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

SECTION II: LANGUAGE BASICS

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

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

Building Java Programs

Transcription:

Operators Questions https://www.geeksforgeeks.org/java-operators-question-1/ https://www.indiabix.com/java-programming/operators-andassignments/ http://www.instanceofjava.com/2015/07/increment-decrementoperators-interview.html https://studyopedia.com/java/java-operators-interview-questions/ https://www.careerride.com/java-operator.aspx https://www.geeksforgeeks.org/java-operators-question-1/ Predict the output of following Java Program class Test public static void main(string args[]) int x = -4; System.out.println(x>>1); int y = 4; System.out.println(y>>1); https://www.geeksforgeeks.org/java-operators-question-2/ Predict the output of following Java program. Assume that int is stored using 32 bits. class Test public static void main(string args[]) int x = -1; System.out.println(x>>>29); System.out.println(x>>>30); System.out.println(x>>>31); https://www.geeksforgeeks.org/java-operators-question-3/ class Test public static void main(string args[]) System.out.println(10 + 20 + "GeeksQuiz"); System.out.println("GeeksQuiz" + 10 + 20); https://www.geeksforgeeks.org/java-operators-question-4/ class Test public static void main(string args[]) System.out.println(10*20 + "GeeksQuiz"); System.out.println("GeeksQuiz" + 10*20); https://www.geeksforgeeks.org/java-operators-question-5/ Which of the following is not an operator in Java? (A) instanceof (B) sizeof

(C) new (D) >>>= https://www.geeksforgeeks.org/java-operators-question-6/ class Base class Derived extends Base public static void main(string args[]) Base a = new Derived(); System.out.println(a instanceof Derived); https://www.geeksforgeeks.org/java-operators-question-7/ class Test public static void main(string args[]) String s1 = "geeksquiz"; String s2 = "geeksquiz"; System.out.println("s1 == s2 is:" + s1 == s2); https://www.indiabix.com/java-programming/operators-andassignments/ What will be the output of the program? class PassA public static void main(string [] args) PassA p = new PassA(); p.start(); void start() long [] a1 = 3,4,5; long [] a2 = fix(a1); System.out.print(a1[0] + a1[1] + a1[2] + " "); System.out.println(a2[0] + a2[1] + a2[2]); long [] fix(long [] a3) a3[1] = 7; return a3; What will be the output of the program? class Test public static void main(string [] args)

Test p = new Test(); p.start(); void start() boolean b1 = false; boolean b2 = fix(b1); System.out.println(b1 + " " + b2); boolean fix(boolean b1) b1 = true; return b1; What will be the output of the program? class PassS public static void main(string [] args) PassS p = new PassS(); p.start(); void start() String s1 = "slip"; String s2 = fix(s1); System.out.println(s1 + " " + s2); String fix(string s1) s1 = s1 + "stream"; System.out.print(s1 + " "); return "stream"; What will be the output of the program? class BitShift public static void main(string [] args) int x = 0x80000000; System.out.print(x + " and "); x = x >>> 31; System.out.println(x); What will be the output of the program? class Equals public static void main(string [] args)

int x = 100; double y = 100.1; boolean b = (x = y); /* Line 7 */ System.out.println(b); http://www.instanceofjava.com/2015/07/increment-decrementoperators-interview.html Java Interview program on pre increment operator 1. class IncrementDemo 5. int a, b; 6. a=10; b=++a; 8. System.out.println(b); 10. 11. Java Interview program on post increment operator 1. class IncrementDemo 5. int a, b; 6. a=10; b=a++; 10. 11. Java Interview program on pre increment operator in expression 1. class IncrementDemo 6. a= ++a + 1;

10. 11. Java Interview program on post increment operator in expression 1. class IncrementDemo 6. a= a++ + 1; 10. 11. Java Interview program on pre increment operator in expression 1. class IncrementDemo 6. a= ++a + ++a; 10. 11. Java Interview program on post increment operator in expression 1. class IncrementDemo 6. a= a++ + a++; 10. 11. Java Interview program on pre and post increment operator in expression 1. class IncrementDemo

6. a= a++ + ++a; 10. Java Interview program on pre decrement 1. class IncrementDemo 5. int a, b; 6. a=10; b=--a; 8. System.out.println(b); 10. 11. Java Interview program on post decrement 1. class IncrementDemo 5. int a, b; 6. a=30; b=a--; 10. 11. Java Interview program on pre decrement in expression 1. class IncrementDemo 6. a= --a - 1; 10. 11. Java Interview program on post decrement in expression

1. class IncrementDemo 6. a= a-- - 1; 10. 11. Java Interview program on pre decrement in expression 1. class IncrementDemo 6. a= --a - --a; 10. 11. Java Interview program on post decrement operator in expression 1. class IncrementDemo 6. a= a-- - a--; 10. 11. Java Interview program on pre and post decrement operator in expression 1. class IncrementDemo 6. a= a-- - --a; 10.

11. Java Interview program on increment and decrement operator in expression 1. class IncrementDemo 6. a= a-- + ++a; 10. 11. Increment and decrement operators Inside println() method 1. class IncrementDemo 5. int a=1; 6. System.out.println(a++); 8. System.out.println(a++); System.out.println(++a); 10. 11. System.out.println(a++); 1 System.out.println(a++); 13. 1 System.out.println(a--); 15. System.out.println(a--); 16. 1 System.out.println(--a); 18. System.out.println(--a); 1 System.out.println(a--); 20. 21. 2 Java Interview program on increment and decrement operator in println 1. class IncrementDemo 5. int i=15; 6. System.out.println(i++); System.out.println(i--); 8.

10. Java Interview program on increment and decrement operator in println 1. class IncrementDemo 5. int a=10,b=10; 6. for(int i=0;i<5;i++) 8. if(++a>2 ++b>2) 10. a++; 11. 1 13. 1 System.out.println("a= "+a+" b="+b); 15. 16. 1 Java Interview program on increment and decrement operator in loops 1. class IncrementDemo 5. int i; 6. for( i=1;i<4;i++) 8. System.out.println(i); 10. 11. 1 System.out.println("value of i after completion of loop: "+i); 13. 1 15. Java Interview program on increment and decrement 1. public class A 3. static int a = 1111; 5. static 6. a = a-- - --a; 8.

10. 11. a = a++ + ++a; 1 13. 1 public static void main(string[] args) 15. 16. System.out.println(a); 1 18. 1 20. https://studyopedia.com/java/java-operators-interview-questions/

What is a Modulus Operator? Show the usage of Modulus Operator with an example program What are Compound Assignment Operators? Give an example showing the usage of Compound Assignment Operators? Why compound assignment operators are used, since the same operation can be done normally as shown above? What is the difference between ++x and x++ under increment operators? Explain the above concept of increment operator with code snippets? Write a complete program explaining the increment and decrement operators in Java? What are Bitwise Logical Operators? What is the role of Bitwise NOT Operator (~)? Give an example? What is Bitwise AND Operator (&). Give an example? Explain Bitwise OR operator? https://studyopedia.com/java/java-bitwise-operators-interview-questions/

Explain Bitwise OR operator? Give an example of Bitwise OR operator ( )? What does a Bitwise left-shift operator do? What does a Bitwise right-shift operator do? How both Bitwise left and right shift operators can be easily differentiated? Give an example of compound bitwise operator assignments? What are logical binary operators? What is the role of Logical Unary NOT? What are short-circuit logical operators? Is this correct in Java? int a, b, c; a = b = c = 5; What is a conditional (ternary) operator? Explain conditional operator with an example program? Operators in the same row are equal in precedence? True or False? Why Parentheses is used? Give an example of using Parenthesis? https://www.careerride.com/java-operator.aspx