Skip to main content

ads1

Class 12th Chpater -7 Java Basics




Java is an object-oriented programming language developed by Sun Microsystems, a company best known for its high-end Unix workstations.

Introduction to Java Java language was developed at Sun Microsystems in 1991.  Java is small, fast, efficient, and easily portable to a wide range of hardware devices. also a general-purpose programming language for developing programs that are easily usable and portable across different platforms.

Java is an object-oriented language and here it differs from C. Using Java, we can take full advantage of object oriented methodology and its capabilities of creating flexible, modular and reusable code.

Control Structures :- In general, the statements are executed sequentially, one by one. Sometimes, program logic needs to change the flow of this sequence. The statements that enable to control the flow of are considered as control structures.

There are two types of control structures: loops and branches. Loops are used to repeat a sequence of statements over and over until some condition occurs. Branches are used to choose among two or more possible courses of action, so also called selective structure.


There are 8 basic data types supported in Java.
Data types
Variables
Literals
Comments
Java statements and expressions
Arithmetic operators
Comparisons
Logical operators


 

(1) How many basic (primitive) data types are supported in Java ?

(a) 2    (b) 4     (c) 8      (d) 16

(2) What is the default data type of floating point literal ?

(a) int     (b) long     (c) float     (d) double

(3) Which character set is used for char data type in Java?

(a) Unicode        (b) ASCII      (c) EBCIDIC      (d) All of these

(4) Which of the following is compiled error free?

(a) for(;;) {int i=7};     (b) while (1){int i=7};   (c) while (True){int i=7};   (d) All of these

(5) Which of the following is not allowed as first character in valid variable name?

(a) Underscore      (b) Digit    (c) Letter   (d) Dollar ($)

(6) Which of the following is not a basic data type in Java ?

(a) char (b) long (c) byte (d) String

(7) What is the default value of boolean type data ?

(a) null      (b) true    (c) false    (d) 0  

(8) What will be the result of arithmetic expression 7/2 ?

(a) 3     (b) 3.5     (c) 1    (d) 0
   
(9) What will be the result of arithmetic expression -7%2?

(a) -3    (b) -1     (c) 1     (d)-3.5

(10) What will be the result of arithmetic expression -7.5%2 ?

(a) -3    (b) -1.5    (c) 1.5    (d) Error 

 

Link to download MCQ :- 




 
 

ads2

Popular posts from this blog

11. Write a Java program to input basic salary of an employee and calculate its Gross salary according to following:

    11. Write a Java program to input basic salary of an employee and calculate its Gross salary according to following: Basic Salary <= 10000 : HRA = 20%, DA = 80% Basic Salary <= 20000 : HRA = 25%, DA = 90% Basic Salary > 20000 : HRA = 30%, DA = 95% Static Solution :-  class salary {     public static void main(String args[])     {     double basic=20000.50,gross,da,hra;     if(basic <=10000)     {         da = basic * 0.8;         hra = basic *0.2;     }              else if(basic <=20000)     {         da = basic * 0.9;         hra = basic *0.25;     }     else     {         da = basic * 0.95;         hra = basic * 0.3;     }     gross = basic + da + hra;     System.out.println("The Gross Salary is :-"+gross);     } } Output :-  Dynamic Solution :-  class salary {     public static void main(String args[])     {     double basic=20000.50,gross,da,hra;     Scanner in = new Scanner(System.in);     System.out.println("Enter the Basic Salary

1. Given the school result data, analyses the performance of the students on #different parameters, e.g subject wise or class wise.

1. Given the school result data, analyses the performance of the students on #different parameters, e.g subject wise  or class wise. Solution :-   # x-axis is shows the subject and y -axis # shows the markers in each subject # import pandas and matplotlib  import pandas as pd  import matplotlib.pyplot as plt # Simple Line Chart with setting of Label of X and Y axis, # title for chart line and color of line  subject = ['Physic','Chemistry','Mathematics', 'Biology','Computer'] marks =[80,75,70,78,82] # To draw line in red colour plt.plot(subject,marks,'r',marker ='*')     # To Write Title of the Line Chart plt.title('Marks Scored') # To Put Label At Y Axis plt.xlabel('SUBJECT')           # To Put Label At X Axis plt.ylabel('MARKS')             plt.show() Output :- 

24.Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category.

24.Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category. import pandas as pd  # initialize list of lists data = [['CAR','Maruti',1000000],['AC','Hitachi',55000],['AIRCOLLER','Bajaj',12000], ['WASHING MACHINE','LG',15000],['CAR','Ford',7000000],['AC','SAMSUNG',45000],['AIRCOLLER','Symphony',20000],['WASHING MACHINE','Wirlpool',25000]] Col=['itemcat','itemname','expenditure'] # Create the pandas DataFrame qrtsales = pd.DataFrame(data,columns=Col) # print dataframe.  print (qrtsales) qs=qrtsales.groupby('itemcat')  print('Result after Filtering Dataframe')  print(qs['itemcat','expenditure'].sum()) Output :-